{"id":14778,"date":"2021-10-28T06:00:00","date_gmt":"2021-10-27T21:00:00","guid":{"rendered":"https:\/\/www.muscle-hypertrophy.com\/?p=14778"},"modified":"2021-10-18T15:39:48","modified_gmt":"2021-10-18T06:39:48","slug":"sql-server-%e3%81%ae-rank-%e9%96%a2%e6%95%b0%ef%bc%8cntile-%e9%96%a2%e6%95%b0%e3%82%92%e4%bd%bf%e3%81%86","status":"publish","type":"post","link":"https:\/\/www.muscle-hypertrophy.com\/?p=14778","title":{"rendered":"SQL Server \u306e RANK \u95a2\u6570\uff0cNTILE \u95a2\u6570\u3067\u9806\u4f4d\uff0c\u56db\u5206\u4f4d\u3092\u53d6\u5f97\u3059\u308b"},"content":{"rendered":"\n<p>\u3000<a href=\"https:\/\/www.muscle-hypertrophy.com\/?p=14746\" target=\"_blank\" rel=\"noopener\">SQL Server \u3067\u30a6\u30a3\u30f3\u30c9\u30a6\u95a2\u6570\u3092\u4f7f\u3044\uff0c1\u884c\u524d\u306e\u884c\u3092\u53d6\u5f97\u3059\u308b<\/a>\u3067\u306f\u30a6\u30a3\u30f3\u30c9\u30a6\u95a2\u6570\u3092\u7528\u3044\u30661\u884c\u524d\u306e\u884c\u3092\u53d6\u5f97\u3057\u305f\uff0e\u4eca\u56de\u306f <a href=\"https:\/\/docs.microsoft.com\/ja-jp\/sql\/t-sql\/functions\/rank-transact-sql?view=sql-server-ver15\" target=\"_blank\" rel=\"noopener\">RANK \u95a2\u6570<\/a>\uff0c<a href=\"https:\/\/docs.microsoft.com\/ja-jp\/sql\/t-sql\/functions\/ntile-transact-sql?view=sql-server-ver15\" target=\"_blank\" rel=\"noopener\">NTILE \u95a2\u6570<\/a>\u3092\u7528\u3044\u3066\u9806\u4f4d\uff0c\u56db\u5206\u4f4d\u3092\u5f97\u308b\uff0e<\/p>\n<p><!--more--><\/p>\n<h2>\u30c6\u30fc\u30d6\u30eb\u5b9a\u7fa9<\/h2>\n<p>\u3000\u30c6\u30fc\u30d6\u30eb\u5b9a\u7fa9\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3042\u308b\uff0e<\/p>\n<pre>CREATE TABLE [dbo].[Temperature](\n\t[\u5e74\u6708\u65e5] [date] NOT NULL,\n\t[\u90fd\u9053\u5e9c\u770c] [nvarchar](50) NOT NULL,\n\t[\u65e5\u5225\u6700\u9ad8\u6c17\u6e29] [float] NOT NULL,\n\t[\u90fd\u9053\u5e9c\u770c\u30b3\u30fc\u30c9] [nvarchar](2) NOT NULL\n) ON [PRIMARY]\nGO<\/pre>\n<h2>\u30af\u30a8\u30ea<\/h2>\n<p>\u3000\u4e0b\u8a18\u30af\u30a8\u30ea\u3092\u767a\u884c\u3057\u3066\u7d50\u679c\u3092\u5f97\u308b\uff0e<\/p>\n<pre>USE EMERGENCYDB;\nGO\nSELECT\t*\n,\tRANK()\tOVER(PARTITION BY \u90fd\u9053\u5e9c\u770c\u30b3\u30fc\u30c9\tORDER BY \u65e5\u5225\u6700\u9ad8\u6c17\u6e29\tDESC)\tAS 'RANK'\n,\tNTILE(4)OVER(PARTITION BY \u90fd\u9053\u5e9c\u770c\u30b3\u30fc\u30c9\tORDER BY \u65e5\u5225\u6700\u9ad8\u6c17\u6e29\tDESC)\tAS 'QUARTILE'\nFROM\tdbo.Temperature<\/pre>\n<h2>\u7d50\u679c<\/h2>\n<p>\u3000\u6700\u521d\u306e 10 \u884c\u306e\u307f\u7d50\u679c\u3092\u8868\u793a\u3059\u308b\uff0e\u90fd\u9053\u5e9c\u770c\u3054\u3068\u306b\u65e5\u5225\u6700\u9ad8\u6c17\u6e29\u306e\u30e9\u30f3\u30ad\u30f3\u30b0\u3092\u884c\u3063\u3066\u3044\u308b\uff0e<\/p>\n<pre>\u5e74\u6708\u65e5\t\u90fd\u9053\u5e9c\u770c\t\u65e5\u5225\u6700\u9ad8\u6c17\u6e29\t\u90fd\u9053\u5e9c\u770c\u30b3\u30fc\u30c9\tRANK\tQUARTILE\n2017-07-14\t\u5317\u6d77\u9053\t34.9\t1\t1\t1\n2015-08-05\t\u5317\u6d77\u9053\t34.5\t1\t2\t1\n2020-08-19\t\u5317\u6d77\u9053\t34.3\t1\t3\t1\n2019-08-02\t\u5317\u6d77\u9053\t34.2\t1\t4\t1\n2019-05-27\t\u5317\u6d77\u9053\t34.2\t1\t4\t1\n2010-08-30\t\u5317\u6d77\u9053\t34.1\t1\t6\t1\n2018-07-31\t\u5317\u6d77\u9053\t33.9\t1\t7\t1\n2011-08-11\t\u5317\u6d77\u9053\t33.8\t1\t8\t1\n2014-06-04\t\u5317\u6d77\u9053\t33.7\t1\t9\t1\n2019-07-30\t\u5317\u6d77\u9053\t33.5\t1\t10\t1<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u3000SQL Server \u3067\u30a6\u30a3\u30f3\u30c9\u30a6\u95a2\u6570\u3092\u4f7f\u3044\uff0c1\u884c\u524d\u306e\u884c\u3092\u53d6\u5f97\u3059\u308b\u3067\u306f\u30a6\u30a3\u30f3\u30c9\u30a6\u95a2\u6570\u3092\u7528\u3044\u30661\u884c\u524d\u306e\u884c\u3092\u53d6\u5f97\u3057\u305f\uff0e\u4eca\u56de\u306f RANK \u95a2\u6570\uff0cNTILE \u95a2\u6570\u3092\u7528\u3044\u3066\u9806\u4f4d\uff0c\u56db\u5206\u4f4d\u3092\u5f97\u308b\uff0e<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[7901,2884,6372,7169,2885,4673,6744,11281,11278,7065,4674,11266,11267,11282,11280,11277,4672,11276,11258,2783,462,11283,11279,11284,11182,4439,11285],"class_list":{"0":"post-14778","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-technology","7":"tag-create-table","8":"tag-date","9":"tag-dbo","10":"tag-desc","11":"tag-float","12":"tag-from","13":"tag-not-null","14":"tag-ntile","16":"tag-nvarchar","17":"tag-order-by","18":"tag-over","19":"tag-partition-by","20":"tag-quartile","21":"tag-rank","23":"tag-select","24":"tag-sql-serve","25":"tag-11258","26":"tag-2783","27":"tag-462","28":"tag-11283","29":"tag-11279","30":"tag-11284","31":"tag-11182","32":"tag-4439","33":"tag-11285"},"_links":{"self":[{"href":"https:\/\/www.muscle-hypertrophy.com\/index.php?rest_route=\/wp\/v2\/posts\/14778","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.muscle-hypertrophy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.muscle-hypertrophy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.muscle-hypertrophy.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.muscle-hypertrophy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=14778"}],"version-history":[{"count":11,"href":"https:\/\/www.muscle-hypertrophy.com\/index.php?rest_route=\/wp\/v2\/posts\/14778\/revisions"}],"predecessor-version":[{"id":14790,"href":"https:\/\/www.muscle-hypertrophy.com\/index.php?rest_route=\/wp\/v2\/posts\/14778\/revisions\/14790"}],"wp:attachment":[{"href":"https:\/\/www.muscle-hypertrophy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=14778"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.muscle-hypertrophy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=14778"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.muscle-hypertrophy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=14778"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}