{"id":177221,"date":"2013-04-19T21:41:03","date_gmt":"2013-04-19T17:41:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=177221"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=177221","title":{"rendered":"<span class=\"post_title\">MS SQL: \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u043f\u0441\u0435\u0432\u0434\u043e\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c newID(). \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0438 \u043f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0435 \u043a\u0430\u043c\u043d\u0438<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0418\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0447\u0442\u043e \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f newID() \u0448\u0438\u0440\u043e\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c\u0438 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u043f\u0440\u044f\u043c\u043e\u043c\u0443 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u2014 \u0442\u043e \u0435\u0441\u0442\u044c \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u044b\u0445 \u043a\u043b\u044e\u0447\u0435\u0439, \u043d\u043e \u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u043f\u0441\u0435\u0432\u0434\u043e\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. <a name=\"habracut\"><\/a><br \/>  \u0412 \u0441\u043e\u0441\u0442\u0430\u0432\u0435 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, newID() \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e non-deterministic, \u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0438 \u00absuper-non-deterministic\u00bb, \u0442.\u043a. \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445, \u043e\u043d\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u0430 \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043d\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438, \u0430 \u043d\u0435 \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435 \u0434\u043b\u044f \u0432\u0441\u0435\u0433\u043e \u0431\u0430\u0442\u0447\u0430 \u2014 \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0435\u0435 \u0447\u0440\u0435\u0437\u0432\u044b\u0447\u0430\u0439\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439 \u0434\u043b\u044f \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0439 \u043c\u0430\u0441\u0441\u043e\u0432\u043e\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438. \u041a\u0440\u043e\u043c\u0435 newID() \u044d\u0442\u0438\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u0435\u0449\u0435 newSequentialID(), \u043e\u0434\u043d\u0430\u043a\u043e \u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0433\u0434\u0435-\u043b\u0438\u0431\u043e, \u043a\u0440\u043e\u043c\u0435 \u043a\u0430\u043a \u0432 \u0437\u0430\u0434\u0430\u043d\u0438\u0438 \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0442\u0438\u043f\u0430 uniqueidentifier, \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u043e.<br \/>  \u0417\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u0434\u0430\u043b\u0435\u043a\u043e \u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0435 \u043d\u0430\u0434\u043e \u2014 \u043d\u0438\u0436\u0435 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"sql\">SELECT TOP 100 ABS(CHECKSUM(NEWID())) % 1000 FROM sysobjects A CROSS JOIN sysobjects B <\/code><\/pre>\n<p>  \u0438\u043b\u0438 \u0432\u043e\u0442 \u044d\u0442\u043e\u0442 (\u0435\u0441\u043b\u0438 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0447\u0442\u043e checksum \u2014 \u0442\u0440\u0443\u0434\u043e\u0435\u043c\u043a\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f):<\/p>\n<pre><code class=\"sql\">SELECT TOP 100 ABS(CONVERT(INT, (CONVERT(BINARY(4), (NEWID()))))) % 1000 FROM sysobjects A CROSS JOIN sysobjects B <\/code><\/pre>\n<p>  \u0421\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043d\u0430\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438\u0437 100 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u043e\u0442 0 \u0434\u043e 999.<\/p>\n<p>  \u0414\u043b\u044f \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0438\u0445 \u0447\u0438\u0441\u0435\u043b \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 rand() \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0446\u0435\u043b\u044b\u043c \u0447\u0438\u0441\u043b\u043e\u043c:<\/p>\n<pre><code class=\"sql\">SELECT TOP 100 RAND(CHECKSUM(NEWID())) FROM sysobjects A CROSS JOIN sysobjects B <\/code><\/pre>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 rand() \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u043e \u0441\u0443\u0442\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u0430\u043a \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430 int32 \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d [0..1). \u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u043d\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u0430 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u043e\u043d\u043e \u043d\u0435 \u0443\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e rand(), \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c\u0443 \u043e\u0434\u0438\u043d \u0440\u0430\u0437, \u0438 \u0434\u0430\u043b\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u043c\u0443 \u0432 \u0446\u0438\u043a\u043b\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u2014 \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043c\u0435\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>  \u0415\u0449\u0435 \u043e\u0434\u0438\u043d \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u2014 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e-\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0417\u0434\u0435\u0441\u044c \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <a href=\"http:\/\/ru.wikipedia.org\/wiki\/%D0%9F%D1%80%D0%B5%D0%BE%D0%B1%D1%80%D0%B0%D0%B7%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5_%D0%91%D0%BE%D0%BA%D1%81%D0%B0_%E2%80%94_%D0%9C%D1%8E%D0%BB%D0%BB%D0%B5%D1%80%D0%B0\">\u0411\u043e\u043a\u0441\u0430-\u041c\u044e\u043b\u043b\u0435\u0440\u0430<\/a>:<\/p>\n<pre><code class=\"sql\">SELECT TOP 1000       COS(2 * PI() * RAND(BINARY_CHECKSUM(NEWID()))) *       SQRT(-2 * LOG(RAND(BINARY_CHECKSUM(NEWID())))) FROM sysobjects A CROSS JOIN sysobjects B CROSS JOIN sysobjects C <\/code><\/pre>\n<p>  \u0416\u0435\u043b\u0430\u044e\u0449\u0438\u0435 \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043e\u0447\u0435\u043d\u044c \u0431\u043b\u0438\u0437\u043a\u043e \u043a \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u043c\u0443, \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0432 \u0433\u0440\u0430\u0444\u0438\u043a.<\/p>\n<p>  \u0412\u0441\u0435 \u044d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0445\u043e\u0442\u044c \u0434\u0435\u0441\u044f\u0442\u043e\u043a \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432 \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u00ab\u0432 \u043b\u043e\u0431\u00bb \u0442\u0438\u043f\u0430 \u0446\u0438\u043a\u043b\u043e\u0432, \u043a\u0443\u0440\u0441\u043e\u0440\u043e\u0432, \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u0432 \u0431\u0430\u0437\u0443 \u0438\u0437 \u0441\u043b\u043e\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041d\u0443\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u043a\u0430\u043a \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0441\u0442\u0440\u043e\u043a, \u0438\u043c\u0435\u044e\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u0443\u044e \u0435\u043c\u043a\u043e\u0441\u0442\u044c, \u0438 \u043b\u0438\u0431\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e CROSS JOIN&#8217;\u043e\u0432, \u043b\u0438\u0431\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441 \u043d\u0443\u0436\u043d\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0441\u0442\u0440\u043e\u043a \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430.<\/p>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e, \u0442\u0435\u043c\u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0431 \u044d\u0442\u043e\u043c. \u0412 \u043f\u043e\u0434\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u044e\u0442\u0441\u044f, \u0442\u043e \u0435\u0441\u0442\u044c \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u0443\u044e \u0438\u043b\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u043b\u0438\u0431\u043e \u0432 \u0442\u0430\u0431\u043b\u0438\u0447\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u0442\u0430\u043a, \u0442\u043e \u0434\u0430\u043b\u044c\u0448\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0435 \u0447\u0438\u0442\u0430\u0442\u044c \u2014 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043e\u0442\u043b\u0438\u0447\u043d\u043e. \u041e\u0434\u043d\u0430\u043a\u043e, \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u0441\u043b\u0443\u0447\u0430\u0438, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b\u0448\u0435\u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0441\u0442\u0435\u0439\u0442\u043c\u0435\u043d\u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445. \u0418 \u0432\u043e\u0442 \u0437\u0434\u0435\u0441\u044c \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0442\u0440\u0443\u0434\u043d\u043e\u043e\u0431\u044a\u044f\u0441\u043d\u0438\u043c\u044b\u0435 \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f SQL engine. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0438\u0445 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u0438 \u043a\u0430\u043a \u0441 \u044d\u0442\u0438\u043c \u0431\u043e\u0440\u043e\u0442\u044c\u0441\u044f:<\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u043f\u0438\u0448\u0435\u043c statement \u0441 newID() \u0432 subquery \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0435\u0433\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u0432 \u0446\u0438\u043a\u043b\u0435:<\/p>\n<pre><code class=\"sql\">declare @c int = 0 while @c &lt; 5 begin   SELECT *    FROM (       SELECT ABS(CONVERT(INT, CONVERT(BINARY(4), NEWID()))) % 5 AS RNDIDX       FROM ( \tSELECT 1 AS ID \t) ROWSRC    ) SUBQ     set @c = @c + 1 end <\/code><\/pre>\n<p>  \u041a\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e \u2014 \u0432\u044b\u0434\u0430\u0435\u0442 5 \u0440\u0435\u0437\u0430\u043b\u0442\u0441\u0435\u0442\u043e\u0432, \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0441\u0442\u0440\u043e\u0433\u043e \u043e\u0434\u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c \u0441 \u0447\u0438\u0441\u043b\u043e\u043c \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u043e\u0442 0 \u0434\u043e 4. \u0421\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u044f \u043d\u0435 \u043f\u0440\u0438\u0432\u043e\u0436\u0443 \u2014 \u043a\u043e\u0433\u0434\u0430 \u0438 \u0442\u0430\u043a \u0432\u0441\u0435 \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u0441\u043c\u044b\u0441\u043b\u0430 \u0432 \u043d\u0438\u0445 \u043c\u0430\u043b\u043e.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435. \u041f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u043e\u0434\u0436\u043e\u0439\u043d\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u0437 SUBQ \u043d\u0430 \u043a\u0430\u043a\u0443\u044e-\u043d\u0438\u0431\u0443\u0434\u044c \u0434\u0440\u0443\u0433\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443. \u0415\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c, \u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0436\u043e\u0439\u043d\u0438\u0442\u044c subquery \u043d\u0430 subquery \u2014 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f. \u041f\u0438\u0448\u0435\u043c:<\/p>\n<pre><code class=\"sql\">declare @c int = 0 while @c &lt; 5 begin   SELECT *    FROM (       SELECT ABS(CONVERT(INT, CONVERT(BINARY(4), NEWID()))) % 5 AS RNDIDX       FROM ( \tSELECT 1 AS ID \t) ROWSRC   ) SUBQ   INNER JOIN ( \tSELECT 0 AS VAL  \tUNION ALL SELECT 1  \tUNION ALL SELECT 2  \tUNION ALL SELECT 3  \tUNION ALL SELECT 4   ) NUM ON SUBQ.RNDIDX = NUM.VAL     set @c = @c + 1 end <\/code><\/pre>\n<p>  \u0421\u043c\u043e\u0442\u043e\u0440\u0438\u043c \u043d\u0430 \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u2014 \u0438 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e \u0441\u043f\u043e\u043b\u0437\u0430\u0435\u043c \u043f\u043e\u0434 \u0441\u0442\u0443\u043b \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u043e\u043a \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0440\u0435\u0437\u0430\u043b\u0442\u0441\u0435\u0442\u0435 \u043d\u0435 \u0440\u0430\u0432\u043d\u043e \u0441\u0442\u0440\u043e\u0433\u043e 1. \u0413\u0434\u0435-\u0442\u043e \u043f\u0443\u0441\u0442\u043e (\u044d\u0442\u043e \u0435\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u0445\u043e\u0442\u044c \u043a\u0430\u043a-\u0442\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u2014 \u043d\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b INNER JOIN \u0438\u0437-\u0437\u0430 \u0432\u044b\u0445\u043e\u0434\u0430 RNDIDX \u0438\u0437 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430 [0..4] (\u0447\u0442\u043e \u0441\u0430\u043c\u043e \u043f\u043e \u0441\u0435\u0431\u0435 \u043d\u0435\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e!)), \u0430 \u0433\u0434\u0435-\u0442\u043e \u2014 \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0434\u043d\u043e\u0439 (!) \u0437\u0430\u043f\u0438\u0441\u0438. <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/-wQKahIsVeBg\/UW-_Fn9to-I\/AAAAAAAAAAs\/XjiK7LuKpPU\/s487\/resultset1.gif\" alt=\"image\"\/><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0435\u043b\u0430\u0435\u043c \u043d\u0435\u0432\u0438\u043d\u043d\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u2014 \u043c\u0435\u043d\u044f\u0435\u043c INNER \u043d\u0430 LEFT:<\/p>\n<pre><code class=\"sql\">declare @c int = 0 while @c &lt; 5 begin   SELECT *    FROM (       SELECT ABS(CONVERT(INT, CONVERT(BINARY(4), NEWID()))) % 5 AS RNDIDX       FROM ( \tSELECT 1 AS ID \t) ROWSRC   ) SUBQ   LEFT JOIN ( \tSELECT 0 AS VAL  \tUNION ALL SELECT 1  \tUNION ALL SELECT 2  \tUNION ALL SELECT 3  \tUNION ALL SELECT 4   ) NUM ON SUBQ.RNDIDX = NUM.VAL     set @c = @c + 1 end <\/code><\/pre>\n<p>  \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u2014 \u0432\u0441\u0435 \u0441\u0442\u0430\u043b\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e (!) \u2014 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u0440\u044c\u0442\u0435 \u043f\u043b\u0437 \u0441\u0430\u043c\u0438, \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u0430 \u0434\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u044f \u043d\u0435 \u0434\u0435\u043b\u0430\u043b. \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f RNDIDX \u0438\u0437 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430 [0..4], \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e \u0432\u044b\u0434\u0430\u0442\u044c \u0441\u0430\u0431\u043a\u0432\u0435\u0440\u0438 SUBQ, \u0432\u0441\u0435\u0433\u0434\u0430 \u0435\u0441\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 VAL \u0438\u0437 \u0441\u0430\u0431\u043a\u0432\u0435\u0440\u0438 NUM, \u0442\u043e \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043b\u043e\u0433\u0438\u043a\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 LEFT \u0438 INNER JOIN \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432. \u041e\u0434\u043d\u0430\u043a\u043e \u043f\u043e \u0444\u0430\u043a\u0442\u0443 \u044d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a!<\/p>\n<p>  \u0415\u0449\u0435 \u043e\u0434\u0438\u043d \u0442\u0435\u0441\u0442 \u2014 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c INNER, \u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c TOP \/ ORDER BY \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u0430\u0431\u043a\u0432\u0435\u0440\u0438. \u0417\u0430\u0447\u0435\u043c \u2014 \u043e\u0431 \u044d\u0442\u043e\u043c \u043f\u043e\u0437\u0436\u0435, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c:<\/p>\n<pre><code class=\"sql\">declare @c int = 0 while @c &lt; 5 begin    SELECT *    FROM (       SELECT TOP 1 ABS(CONVERT(INT, CONVERT(BINARY(4), NEWID()))) % 5 AS RNDIDX       FROM ( \t\tSELECT 1 AS ID \t\t) ROWSRC \t  ORDER BY RNDIDX\t\t   ) SUBQ   INNER JOIN ( \tSELECT 0 AS VAL  \tUNION ALL SELECT 1  \tUNION ALL SELECT 2  \tUNION ALL SELECT 3  \tUNION ALL SELECT 4   ) NUM ON SUBQ.RNDIDX = NUM.VAL    set @c = @c + 1 end <\/code><\/pre>\n<p>  \u0412\u0441\u0435 \u043e\u043f\u044f\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e! \u041c\u0438\u0441\u0442\u0438\u043a\u0430!<\/p>\n<p>  \u041f\u043e\u0433\u0443\u0433\u043b\u0438\u0432, \u0432\u044b\u044f\u0441\u043d\u044f\u0435\u043c, \u0447\u0442\u043e \u0441 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u043c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044e\u0442\u0441\u044f SQL-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0441\u043e \u0432\u0441\u0435\u0433\u043e \u043c\u0438\u0440\u0430 \u2014 \u043f\u0440\u0438\u043c\u0435\u0440\u044b <a href=\"http:\/\/stackoverflow.com\/questions\/9463938\/checksumnewid-executes-multiple-times-per-row\">\u0437\u0434\u0435\u0441\u044c<\/a>, \u0438\u043b\u0438 <a href=\"http:\/\/social.msdn.microsoft.com\/Forums\/en-US\/transactsql\/thread\/9b1041f7-dc91-4672-94b0-60311b80a121\/\">\u0437\u0434\u0435\u0441\u044c<\/a> <\/p>\n<p>  \u041b\u044e\u0434\u0438 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u044e\u0442, \u0447\u0442\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f subquery \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442. \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u044b\u0431\u0440\u0430\u0432 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u044f\u0432\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0430 \u0437\u0430\u0442\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434\u0436\u043e\u0439\u043d\u0438\u0432, \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e. \u041f\u043e\u0447\u0435\u043c\u0443 \u0436\u0435 \u043d\u0430 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0432\u043b\u0438\u044f\u0435\u0442 \u0437\u0430\u043c\u0435\u043d\u0430 INNER \u043d\u0430 LEFT, \u0438\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 TOP \/ ORDER BY \u0442\u0430\u043c, \u0433\u0434\u0435 \u044d\u0442\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e? \u0412\u0441\u0435 \u043f\u043e\u0442\u043e\u043c\u0443 \u0436\u0435 \u2014 \u0432 \u043e\u0434\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 subquery, \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u2014 \u043d\u0435\u0442. \u041d\u0430\u0433\u043b\u044f\u0434\u043d\u0435\u0435 \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0430\u043d\u0430\u043b\u0438\u0437 \u043f\u043b\u0430\u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u043e\u0442 \u044d\u0442\u043e\u0433\u043e:<\/p>\n<pre><code class=\"sql\">DECLARE @B TABLE (VAL INT) INSERT INTO @B VALUES (0), (1), (2), (3), (4)  SELECT *  FROM (       SELECT ABS(CONVERT(INT, CONVERT(BINARY(4), NEWID()))) % 5 AS RNDIDX       FROM @B ) SUBQ INNER JOIN @B B ON SUBQ.RNDIDX = B.VAL  \u0421\u043c\u043e\u0442\u0440\u0438\u043c \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0431\u043e\u0440\u043a\u0443 (query 2), \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b @B \u043d\u0430\u043c \u043d\u0438 \u043a \u0447\u0435\u043c\u0443: <\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/-SbEQADflEAc\/UW_eq3oA7NI\/AAAAAAAAACY\/y1vfsJe3RUM\/s1110\/execplan1.gif\" alt=\"image\"\/><\/p>\n<p>  \u041c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0437\u0430\u043f\u0440\u043e\u0441 \u0441\u0440\u0430\u0449\u0438\u0432\u0430\u0435\u0442 \u0434\u0432\u0430 \u043f\u043e\u0442\u043e\u043a\u0430 \u0441\u0442\u0440\u043e\u043a \u0434\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u0438, \u0437\u0430\u0432\u0438\u0441\u044f\u0449\u0435\u0439 \u043e\u0442 newID(). \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e SQL engine \u0441\u0447\u0438\u0442\u0430\u0435\u0442, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 newID(), \u0445\u043e\u0442\u044c \u0438 non-deterministic, \u043d\u043e \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0433\u043e \u0431\u0430\u0442\u0447\u0430. \u041e\u0434\u043d\u0430\u043a\u043e, \u044d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a \u2014 \u0438 \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0430\u043f\u0440\u043e\u0441 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u0435\u043d\u044f\u0435\u043c INNER \u043d\u0430 LEFT, \u0438 \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043b\u0430\u043d:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/-_CPThga5zcI\/UW_hf1GooSI\/AAAAAAAAAC0\/3AVcvg1TBpk\/s1111\/execplan2.gif\" alt=\"image\"\/><\/p>\n<p>  \u0410\u0433\u0430, LEFT JOIN \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043b SQL engine \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c Compute Scalar \u043f\u0435\u0440\u0435\u0434 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435\u043c \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0448 \u0437\u0430\u043f\u0440\u043e\u0441 \u0441\u0442\u0430\u043b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e.<\/p>\n<p>  \u0418 \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0432\u0435\u0440\u0441\u0438\u044e \u0441 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c TOP \/ ORDER BY:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/-LH1ksOnbepM\/UW_iWVgJE6I\/AAAAAAAAADQ\/gA3UADaqRrg\/s1111\/execplan3.gif\" alt=\"image\"\/><\/p>\n<p>  \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0434\u0438\u0430\u0433\u043d\u043e\u0437 \u044f\u0441\u0435\u043d. MS SQL \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 newID(), \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0441\u0442\u0440\u043e\u0438\u0442 \u043f\u043b\u0430\u043d\u044b, \u043f\u043e\u043b\u0430\u0433\u0430\u044f\u0441\u044c \u043d\u0430 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u0432 \u0441\u043a\u043e\u0443\u043f\u0435 \u0431\u0430\u0442\u0447\u0430. \u041d\u0430 \u044d\u0442\u0443 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0435\u0441\u0442\u044c \u0432\u043e\u0440\u043a\u044d\u0440\u0430\u0443\u043d\u0434 \u2014 \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c SQL engine \u043b\u044e\u0431\u044b\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0431\u043e\u0440\u043a\u0443, \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c \u043a\u0430\u043a \u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445. \u041a\u0430\u043a\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u2014 \u0434\u0435\u043b\u043e \u0432\u0430\u0448\u0435, \u043e\u0434\u043d\u0430\u043a\u043e \u043b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u043e, \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0435\u0441\u043b\u0438 \u0440\u0430\u0437\u043c\u0435\u0440 \u043f\u043e\u0434\u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u043d\u0435\u0432\u0435\u043b\u0438\u043a. \u0418\u043d\u0430\u0447\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043c\u044f\u0433\u043a\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u043d\u0435 100% \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d; \u043a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043d\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0438, \u0447\u0442\u043e \u043e\u0434\u043d\u0430\u0436\u0434\u044b \u0432\u044b \u0441\u0430\u043c\u0438, \u0438\u043b\u0438 \u043a\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0434\u0440\u0443\u0433\u043e\u0439 \u043d\u0435 \u043e\u0442\u0440\u0435\u0432\u044c\u044e\u0438\u0442 \u043a\u043e\u0434, \u0432\u044b\u043a\u0438\u043d\u0443\u0432 \u00ab\u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0435\u00bb TOP \/ ORDER BY \u0438\u043b\u0438 \u043c\u0443\u0434\u0440\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0432 LEFT \u043d\u0430 INNER.<\/p>\n<p>  \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432\u0441\u0435. \u0423\u0434\u0430\u0447\u043d\u043e\u0433\u043e SQL-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f! \t\t\t \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/177221\/\"> http:\/\/habrahabr.ru\/post\/177221\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0418\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0447\u0442\u043e \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f newID() \u0448\u0438\u0440\u043e\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c\u0438 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u043f\u0440\u044f\u043c\u043e\u043c\u0443 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u2014 \u0442\u043e \u0435\u0441\u0442\u044c \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u044b\u0445 \u043a\u043b\u044e\u0447\u0435\u0439, \u043d\u043e \u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u043f\u0441\u0435\u0432\u0434\u043e\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-177221","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/177221","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=177221"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/177221\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=177221"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=177221"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=177221"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}