{"id":2042,"date":"2011-10-20T15:36:59","date_gmt":"2011-10-20T07:36:59","guid":{"rendered":"http:\/\/jason695.why3s.tw\/wordpress\/?p=2042"},"modified":"2011-10-20T16:27:22","modified_gmt":"2011-10-20T08:27:22","slug":"%e4%bd%bf%e7%94%a8-pivot-%e5%92%8c-unpivot-2","status":"publish","type":"post","link":"https:\/\/jason695.why3s.tw\/wordpress\/2011\/10\/20\/%e4%bd%bf%e7%94%a8-pivot-%e5%92%8c-unpivot-2\/","title":{"rendered":"\u4f7f\u7528 PIVOT \u548c UNPIVOT"},"content":{"rendered":"<p><a href=\"http:\/\/msdn.microsoft.com\/zh-tw\/library\/ms177410.aspx\" target=\"_blank\">http:\/\/msdn.microsoft.com\/zh-tw\/library\/ms177410.aspx<\/a><\/p>\n<p>\u7c21\u55ae\u4f86\u8aaa\u5c31\u662f\u628a\u5831\u8868\u7531\u76f4\u8f49\u6a6b\u3002<\/p>\n<p>PIVOT\u7684\u8a9e\u6cd5\u5206\u4e09\u5c64\uff0c\u7528\u4e09\u500b\u6b65\u9a5f\u4f86\u4f7f\u7528\u3002<br \/>\n\u7b2c\u4e00\u6b65\u9a5f\uff1a\u5148\u628a\u8981PIVOT\u7684\u539f\u59cb\u8cc7\u6599\u67e5\u8a62(Query)\u597d\u3002<br \/>\n\u7b2c\u4e8c\u6b65\u9a5f\uff1a\u8a2d\u5b9a\u597dPIVOT\u7684\u6b04\u4f4d\u8207\u65b9\u5f0f\u3002<br \/>\n\u7b2c\u4e09\u6b65\u9a5f\uff1a\u4f9dPIVOT\u597d\u4e86\u7684\u8cc7\u6599\uff0c\u5448\u73fe\u7d50\u679c\u3002<\/p>\n<p>EX\uff1a<\/p>\n<pre>LogTime  StatusCode Cnt\r\n-------- ---------- -----------\r\n06:40:05 200        5\r\n06:40:05 302        1\r\n06:40:06 304        1\r\n06:40:06 200        10\r\n06:40:07 200        5\r\n06:40:07 500        3\r\n06:40:08 200        11\r\n06:40:08 404        1<\/pre>\n<p>\u8b8a\u6210<\/p>\n<pre>LogTime  200         302         304         401         404         500\r\n-------- ----------- ----------- ----------- ----------- ----------- -----------\r\n06:40:05 5           1           NULL        NULL        NULL        NULL\r\n06:40:06 10          NULL        1           NULL        NULL        NULL\r\n06:40:07 5           NULL        NULL        NULL        NULL        3\r\n06:40:08 11          NULL        NULL        NULL        1           NULL<\/pre>\n<p>\u53e6\u5916\u9644\u4e0a\u76f8\u95dc\u7684\u8a0e\u8ad6\uff1a<br \/>\n<a href=\"http:\/\/blog.darkthread.net\/post-2007-07-20-tips-using-pivot-in-sql-2005.aspx\" target=\"_blank\">http:\/\/blog.darkthread.net\/post-2007-07-20-tips-using-pivot-in-sql-2005.aspx<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>http:\/\/msdn.microsoft.com\/zh-tw\/library\/ms177410.aspx \u7c21 &hellip; <a href=\"https:\/\/jason695.why3s.tw\/wordpress\/2011\/10\/20\/%e4%bd%bf%e7%94%a8-pivot-%e5%92%8c-unpivot-2\/\" class=\"more-link\">\u95b1\u8b80\u5168\u6587 <span class=\"screen-reader-text\">\u4f7f\u7528 PIVOT \u548c UNPIVOT<\/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-2042","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\/2042","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=2042"}],"version-history":[{"count":0,"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/posts\/2042\/revisions"}],"wp:attachment":[{"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/media?parent=2042"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/categories?post=2042"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/tags?post=2042"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}