{"id":14746,"date":"2021-10-14T06:00:00","date_gmt":"2021-10-13T21:00:00","guid":{"rendered":"https:\/\/www.muscle-hypertrophy.com\/?p=14746"},"modified":"2021-10-13T15:57:18","modified_gmt":"2021-10-13T06:57:18","slug":"sql-server-%e3%81%a7%e3%82%a6%e3%82%a3%e3%83%b3%e3%83%89%e3%82%a6%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=14746","title":{"rendered":"SQL Server \u3067\u30a6\u30a3\u30f3\u30c9\u30a6\u95a2\u6570\u3092\u4f7f\u3044\uff0c1\u884c\u524d\u306e\u884c\u3092\u53d6\u5f97\u3059\u308b"},"content":{"rendered":"\n<p>\u3000\u30a6\u30a3\u30f3\u30c9\u30a6\u95a2\u6570\u306f\u6bd4\u8f03\u7684\u65b0\u3057\u3044\u6280\u8853\u3067\u3042\u308b\uff0e\u7b46\u8005\u306f\u6b63\u76f4\uff0cSQL \u304c\u82e6\u624b\u3060\uff0eIPA \u306e\u8a66\u9a13\u304c\u7d42\u308f\u3063\u305f\u306e\u3067\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u95a2\u9023\u306e\u52c9\u5f37\u3092\u518d\u958b\u3057\u3066\u3044\u308b\uff0e<\/p>\n<p><!--more--><\/p>\n<h2>\u30c6\u30fc\u30d6\u30eb\u5b9a\u7fa9<\/h2>\n<p>\u3000\u30c6\u30fc\u30d6\u30eb\u306f\u3059\u3067\u306b\u3042\u308b\u3082\u306e\u3092\u4f7f\u3046\uff0e\u4eca\u56de\u306f<a href=\"https:\/\/www.muscle-hypertrophy.com\/?p=14504\" target=\"_blank\" rel=\"noopener\">\u71b1\u4e2d\u75c7\u306e\u642c\u9001\u4eba\u54e1\u3068\u6700\u9ad8\u6c17\u6e29\u3068\u306e\u76f8\u95a2\u95a2\u4fc2\u3092\u53ef\u8996\u5316\u3057\u95be\u5024\u3092\u03c7\u4e8c\u4e57\u691c\u5b9a\u3059\u308b<\/a>\u3067\u4f5c\u6210\u3057\u305f EMERGENCYDB \u306e Temperature \u30c6\u30fc\u30d6\u30eb\u3092\u4f7f\u3046\uff0e\u5ff5\u306e\u305f\u3081\u30c6\u30fc\u30d6\u30eb\u5b9a\u7fa9\u3092\u8a18\u8ff0\u3057\u3066\u304a\u304f\uff0e<\/p>\n<p>\u3000\u8a72\u5f53\u30c6\u30fc\u30d6\u30eb\u3092\u53f3\u30af\u30ea\u30c3\u30af\u3057\u3066\u300c\u30c6\u30fc\u30d6\u30eb\u3092\u30b9\u30af\u30ea\u30d7\u30c8\u5316\u300d\u300c\u65b0\u898f\u4f5c\u6210\u300d\u300c\u65b0\u3057\u3044\u30af\u30a8\u30ea\u30a8\u30c7\u30a3\u30bf\u30fc\u30a6\u30a3\u30f3\u30c9\u30a6\u300d\u3068\u9032\u3093\u3060\u5148\u306b\u5f97\u3089\u308c\u305f\u3082\u306e\u3067\u3042\u308b\uff0e<\/p>\n<figure id=\"attachment_14749\" aria-describedby=\"caption-attachment-14749\" style=\"width: 637px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.muscle-hypertrophy.com\/wp-content\/uploads\/2021\/10\/00.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-14749\" src=\"https:\/\/www.muscle-hypertrophy.com\/wp-content\/uploads\/2021\/10\/00.png\" alt=\"\u30c6\u30fc\u30d6\u30eb\u3092\u30b9\u30af\u30ea\u30d7\u30c8\u5316\" width=\"637\" height=\"167\" srcset=\"https:\/\/www.muscle-hypertrophy.com\/wp-content\/uploads\/2021\/10\/00.png 637w, https:\/\/www.muscle-hypertrophy.com\/wp-content\/uploads\/2021\/10\/00-300x79.png 300w\" sizes=\"auto, (max-width: 637px) 100vw, 637px\" \/><\/a><figcaption id=\"caption-attachment-14749\" class=\"wp-caption-text\">\u30c6\u30fc\u30d6\u30eb\u3092\u30b9\u30af\u30ea\u30d7\u30c8\u5316<\/figcaption><\/figure>\n<p>\u3000\u4e3b\u30ad\u30fc\u304c\u4f5c\u6210\u3055\u308c\u3066\u3044\u306a\u3044\u304c\uff0c\u3053\u3053\u3067\u306f\u554f\u984c\u306b\u3057\u3066\u3044\u306a\u3044\uff0e\u8a2d\u5b9a\u3059\u308b\u306a\u3089\u300c\u5e74\u6708\u65e5\u300d\u300c\u90fd\u9053\u5e9c\u770c\u30b3\u30fc\u30c9\u300d\u306e\u8907\u5408\u30ad\u30fc\u304c\u305d\u308c\u306b\u5f53\u305f\u308b\uff0e<\/p>\n<pre>USE [EMERGENCYDB]\nGO\nSET ANSI_NULLS ON\nGO\nSET QUOTED_IDENTIFIER ON\nGO\nCREATE 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] 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\u90fd\u9053\u5e9c\u770c\u3054\u3068\u306b\u7fa4\u5225 (<code>PARTITON BY<\/code>) \u3057\u3066\u5e74\u6708\u65e5\u3067\u6607\u9806\u30bd\u30fc\u30c8\u3057\uff0c\u5404\u7fa4\u5185\u3067 1 \u884c\u524d\u306e\u884c\u304b\u3089\u6700\u9ad8\u6c17\u6e29\u3092\u62bd\u51fa\u3057\u3066\u3044\u308b\uff0eBETWEEN\u53e5\u3067 1 \u884c\u524d\u306e\u30d5\u30ec\u30fc\u30e0\u3092\u9078\u629e\u3057\u3066\u3044\u308b\uff0e\u30d5\u30ec\u30fc\u30e0\u5185\u306b\u306f 1 \u884c\u3057\u304b\u5b58\u5728\u3057\u306a\u3044 (<code>BETWEEN 1 PRECEDING AND 1 PRECEDING<\/code>) \u305f\u3081\uff0c\u96c6\u7d04\u95a2\u6570\u306f AVG \u3067\u3082 SUM \u3067\u3082 MAX \u3067\u3082 MIN \u3067\u3082\u69cb\u308f\u306a\u3044\u304c\uff0cCOUNT \u3060\u3051\u306f\u4f7f\u7528\u3057\u3066\u306f\u3044\u3051\u306a\u3044\uff0e<\/p>\n<pre>USE EMERGENCYDB;\nGO\nSELECT\t\u5e74\u6708\u65e5\n, \t\u65e5\u5225\u6700\u9ad8\u6c17\u6e29\tAS \u5f53\u65e5\n,\tMAX(\u65e5\u5225\u6700\u9ad8\u6c17\u6e29)\u3000OVER (PARTITION BY \u90fd\u9053\u5e9c\u770c\u30b3\u30fc\u30c9\tORDER BY \u5e74\u6708\u65e5\n\t\t\t  ROWS  BETWEEN 1 PRECEDING AND 1 PRECEDING) AS \u524d\u65e5\n,\t\u90fd\u9053\u5e9c\u770c\nFROM\tdbo.Temperature<\/pre>\n<h2>\u7d50\u679c<\/h2>\n<p>\u3000\u5168\u90e8\u3067 111708 \u4ef6\u306e\u7d50\u679c\u304c\u5f97\u3089\u308c\u308b\u304c\uff0c\u3053\u3053\u3067\u306f\u6700\u521d\u306e\u6570\u4ef6\u306e\u307f\u3068\u3057\u3066\u304a\u304f\uff0e\u6700\u521d\u306e\u884c\u306e\u300c\u524d\u65e5\u300d\u304c NULL \u306a\u306e\u306f\u3053\u308c\u3088\u308a\u524d\u306e\u884c\u304c\u5b58\u5728\u3057\u306a\u3044\u304b\u3089\u3067\u3042\u308b\uff0e<\/p>\n<pre>\u5e74\u6708\u65e5\t\u5f53\u65e5\t\u524d\u65e5\t\u90fd\u9053\u5e9c\u770c\n2008-04-01\t4.3\tNULL\t\u5317\u6d77\u9053\n2008-04-02\t8.4\t4.3\t\u5317\u6d77\u9053\n2008-04-03\t9.8\t8.4\t\u5317\u6d77\u9053\n2008-04-04\t11.8\t9.8\t\u5317\u6d77\u9053\n2008-04-05\t9.8\t11.8\t\u5317\u6d77\u9053\n2008-04-06\t14.5\t9.8\t\u5317\u6d77\u9053<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u3000\u30a6\u30a3\u30f3\u30c9\u30a6\u95a2\u6570\u306f\u6bd4\u8f03\u7684\u65b0\u3057\u3044\u6280\u8853\u3067\u3042\u308b\uff0e\u7b46\u8005\u306f\u6b63\u76f4\uff0cSQL \u304c\u82e6\u624b\u3060\uff0eIPA \u306e\u8a66\u9a13\u304c\u7d42\u308f\u3063\u305f\u306e\u3067\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u95a2\u9023\u306e\u52c9\u5f37\u3092\u518d\u958b\u3057\u3066\u3044\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":[11263,11262,5471,7901,2884,6743,11264,11265,6744,7065,4674,11266,11267,11268,5470,259,2740,6389,11258,2783,11259,11257,6910,4483,11260,2487,6753,11261,1029],"class_list":["post-14746","post","type-post","status-publish","format-standard","hentry","category-technology","tag-avg","tag-between","tag-count-2","tag-create-table","tag-date","tag-int","tag-max","tag-min","tag-not-null","tag-nvarchar","tag-order-by","tag-over","tag-partition-by","tag-preceding","tag-rows","tag-sql","tag-sql-server","tag-sum","tag-11258","tag-2783","tag-11259","tag-11257","tag-6910","tag-4483","tag-11260","tag-2487","tag-6753","tag-11261","tag-1029"],"_links":{"self":[{"href":"https:\/\/www.muscle-hypertrophy.com\/index.php?rest_route=\/wp\/v2\/posts\/14746","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=14746"}],"version-history":[{"count":14,"href":"https:\/\/www.muscle-hypertrophy.com\/index.php?rest_route=\/wp\/v2\/posts\/14746\/revisions"}],"predecessor-version":[{"id":14764,"href":"https:\/\/www.muscle-hypertrophy.com\/index.php?rest_route=\/wp\/v2\/posts\/14746\/revisions\/14764"}],"wp:attachment":[{"href":"https:\/\/www.muscle-hypertrophy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=14746"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.muscle-hypertrophy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=14746"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.muscle-hypertrophy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=14746"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}