{"id":2018,"date":"2011-10-13T15:43:59","date_gmt":"2011-10-13T07:43:59","guid":{"rendered":"http:\/\/jason695.why3s.tw\/wordpress\/?p=2018"},"modified":"2011-11-30T11:41:40","modified_gmt":"2011-11-30T03:41:40","slug":"row_number%e5%8f%8arank","status":"publish","type":"post","link":"https:\/\/jason695.why3s.tw\/wordpress\/2011\/10\/13\/row_number%e5%8f%8arank\/","title":{"rendered":"ROW_NUMBER\u53caRANK"},"content":{"rendered":"<p><strong>ROW_NUMBER\uff1a<\/strong><\/p>\n<p style=\"color: #ff0000;\">\u5169\u500bTABLE\uff0cT1\u70baMaster\uff0cT2\u70baDetail\uff0c\u53d6\u51fa\u540c\u4e00PK\u5728T2\u7684\u7b2cN\u7b46\u8cc7\u6599<\/p>\n<pre lang=\"SQL\">SELECT *\r\nFROM Table_1 T1\r\n   INNER JOIN (\r\n      SELECT *\r\n             , ROW_NUMBER() OVER (PARTITION BY PK ORDER BY PK) RID\r\n      FROM Table_2) T2\r\n   ON T1.PK = T2.PK\r\n      AND T2.RID = \u53d6\u7b2cN\u7b46<\/pre>\n<p>\u53c3\u8003\uff1a<a href=\"http:\/\/technet.microsoft.com\/zh-tw\/library\/ms186734.aspx\" target=\"_blank\">ROW_NUMBER (Transact-SQL)<\/a><\/p>\n<p><strong>RANK\uff1a<\/strong><\/p>\n<p style=\"color: #ff0000;\">\u5f88\u985e\u4f3cROW_NUMBER\u7684\u7528\u6cd5\uff0c\u4f46\u76f8\u540c\u7684\u8cc7\u6599\u76f8\u540c\u6392\u540d\uff0c\u4e0b\u4e00\u500b\u4e0d\u540c\u6703\u3010\u8df3\u812b\u3011<\/p>\n<pre lang=\"SQL\">SELECT *\r\nFROM Table_1 T1\r\n   INNER JOIN (\r\n      SELECT *\r\n             , RANK() OVER (PARTITION BY PK ORDER BY PK) RID\r\n      FROM Table_2) T2\r\n   ON T1.PK = T2.PK\r\n      AND T2.RID = \u53d6\u7b2cN\u7b46<\/pre>\n<p>\u53c3\u8003\uff1a<a href=\"http:\/\/technet.microsoft.com\/zh-tw\/library\/ms176102.aspx\" target=\"_blank\">RANK (Transact-SQL)<\/a><\/p>\n<p>\u5176\u4ed6\u53c3\u8003\uff1a<a id=\"viewpost_ascx_TitleUrl\" href=\"http:\/\/www.dotblogs.com.tw\/topcat\/archive\/2009\/08\/06\/9906.aspx\">[SQL]\u70ba\u67e5\u8a62\u7684\u7d50\u679c\u52a0\u4e0a\u5e8f\u865f(ROW_NUMBER,RANK,OVER)<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>ROW_NUMBER\uff1a \u5169\u500bTABLE\uff0cT1\u70baMaster\uff0cT2\u70baDetail\uff0c\u53d6\u51fa\u540c\u4e00PK\u5728T2\u7684\u7b2cN\u7b46\u8cc7\u6599 &hellip; <a href=\"https:\/\/jason695.why3s.tw\/wordpress\/2011\/10\/13\/row_number%e5%8f%8arank\/\" class=\"more-link\">\u95b1\u8b80\u5168\u6587 <span class=\"screen-reader-text\">ROW_NUMBER\u53caRANK<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[47],"tags":[],"class_list":["post-2018","post","type-post","status-publish","format-standard","hentry","category-sql-server","no-featured-image"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/posts\/2018","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/comments?post=2018"}],"version-history":[{"count":0,"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/posts\/2018\/revisions"}],"wp:attachment":[{"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/media?parent=2018"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/categories?post=2018"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/tags?post=2018"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}