{"id":3246,"date":"2025-12-18T09:50:16","date_gmt":"2025-12-18T00:50:16","guid":{"rendered":"https:\/\/www.agile-software.site\/?p=3246"},"modified":"2025-12-18T10:22:03","modified_gmt":"2025-12-18T01:22:03","slug":"sql%e3%81%ae%e3%83%91%e3%83%95%e3%82%a9%e3%83%bc%e3%83%9e%e3%83%b3%e3%82%b9","status":"publish","type":"post","link":"https:\/\/agile-software.net\/?p=3246","title":{"rendered":"SQL\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">1. \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306e\u6b63\u4f53\u306f\u300c\u6574\u7406\u3055\u308c\u305f\u8f9e\u66f8\u300d<\/h2>\n\n\n\n<p>\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3068\u306f\u3001\u672c\u306e\u5f8c\u308d\u306b\u3042\u308b\u7d22\u5f15\u3084\u8f9e\u66f8\u306e\u3088\u3046\u306b\u3001<strong>\u30c7\u30fc\u30bf\u304c\u7279\u5b9a\u306e\u9806\u756a\u3067\u4e26\u3093\u3067\u3044\u308b\u72b6\u614b<\/strong>\u3092\u6307\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306f\u3053\u306e\u300c\u4e26\u3073\u9806\u300d\u3092\u5229\u7528\u3057\u3066\u3001\u300c2023-10-01\u300d\u3068\u3044\u3046\u30c7\u30fc\u30bf\u304c\u3069\u3053\u306b\u3042\u308b\u304b\u3092\u3001\u4e8c\u5206\u63a2\u7d22\u306a\u3069\u306e\u52b9\u7387\u7684\u306a\u65b9\u6cd5\u3067\u77ac\u6642\u306b\u898b\u3064\u3051\u51fa\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. \u306a\u305c\u300c\u95a2\u6570\u300d\u3092\u4f7f\u3046\u3068\u9045\u3044\u306e\u304b\uff08\u30a4\u30e1\u30fc\u30b8\u56f3\uff09<\/h2>\n\n\n\n<p>\u95a2\u6570\u3092\u4f7f\u3046\u3068\u3044\u3046\u3053\u3068\u306f\u3001\u300c\u8f9e\u66f8\u306e\u4e2d\u8eab\u3092\u3059\u3079\u3066\u66f8\u304d\u63db\u3048\u3066\u304b\u3089\u63a2\u3059\u300d\u3068\u3044\u3046\u4f5c\u696d\u3092\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u5f37\u3044\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">&#x274c; \u95a2\u6570\u3042\u308a\uff1a<code>TRUNC(created_at)<\/code> \u306e\u5834\u5408<\/h3>\n\n\n\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306f\u3001\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\uff08\u7d22\u5f15\uff09\u306b\u66f8\u304b\u308c\u3066\u3044\u308b\u5143\u306e\u5024\u3092\u305d\u306e\u307e\u307e\u4f7f\u3048\u306a\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><td><strong>\u5143\u306e\u30c7\u30fc\u30bf\uff08\u7d22\u5f15\uff09<\/strong><\/td><td><strong>TRUNC\u95a2\u6570\u9069\u7528\u5f8c\uff08\u8a08\u7b97\u304c\u5fc5\u8981\uff09<\/strong><\/td><td><strong>\u5224\u5b9a<\/strong><\/td><\/tr><\/thead><tbody><tr><td>2023-10-01 10:00<\/td><td>\u2192 2023-10-01<\/td><td>\u4e00\u81f4\uff01<\/td><\/tr><tr><td>2023-10-01 15:30<\/td><td>\u2192 2023-10-01<\/td><td>\u4e00\u81f4\uff01<\/td><\/tr><tr><td>2023-10-02 09:00<\/td><td>\u2192 2023-10-02<\/td><td>\u4e0d\u4e00\u81f4<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><strong>\u306a\u305c\u9045\u3044\uff1f\uff1a<\/strong> \u4e0a\u306e\u56f3\u306e\u3088\u3046\u306b\u3001\u3059\u3079\u3066\u306e\u884c\u3092\u4e00\u884c\u305a\u3064\u53d6\u308a\u51fa\u3057\u3001\u95a2\u6570\u3067\u8a08\u7b97\u3057\u76f4\u3057\u3066\u304b\u3089\u6bd4\u8f03\u3057\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002\u3053\u308c\u3092\u30d5\u30eb\u30c6\u30fc\u30d6\u30eb\u30b9\u30ad\u30e3\u30f3\uff08\u5168\u4ef6\u8d70\u67fb\uff09\u3068\u547c\u3073\u307e\u3059\u3002100\u4e07\u4ef6\u3042\u308c\u3070\u3001100\u4e07\u56de\u8a08\u7b97\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u3001\u975e\u5e38\u306b\u6642\u9593\u304c\u304b\u304b\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. \u306a\u305c\u300c\u7bc4\u56f2\u6307\u5b9a\u300d\u306f\u901f\u3044\u306e\u304b<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">&#x2b55; \u7bc4\u56f2\u6307\u5b9a\uff1a<code>created_at &gt;= '2023-10-01'<\/code> \u306e\u5834\u5408<\/h3>\n\n\n\n<p>\u3053\u3061\u3089\u306f\u3001\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306e\u300c\u4e26\u3073\u9806\u300d\u3092\u305d\u306e\u307e\u307e\u6d3b\u7528\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306e\u4e2d\u304b\u3089\u300c2023-10-01 00:00:00\u300d\u304c\u59cb\u307e\u308b\u5834\u6240\u3092<strong>\u30d4\u30f3\u30dd\u30a4\u30f3\u30c8<\/strong>\u3067\u63a2\u3059\uff08\u4e00\u77ac\uff09\u3002<\/li>\n\n\n\n<li>\u305d\u3053\u304b\u3089\u300c2023-10-02 00:00:00\u300d\u306e\u624b\u524d\u307e\u3067\u3092<strong>\u9806\u756a\u306b\u8aad\u307f\u53d6\u308b\u3060\u3051<\/strong>\uff08\u975e\u5e38\u306b\u901f\u3044\uff09\u3002<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><td><strong>\u51e6\u7406\u30b9\u30c6\u30c3\u30d7<\/strong><\/td><td><strong>\u52d5\u4f5c\u30a4\u30e1\u30fc\u30b8<\/strong><\/td><\/tr><\/thead><tbody><tr><td><strong>\u30b9\u30c6\u30c3\u30d71<\/strong><\/td><td>\u7d22\u5f15\u306e\u300c2023-10-01\u300d\u306e\u30da\u30fc\u30b8\u3092\u30d1\u30c3\u3068\u958b\u304f<\/td><\/tr><tr><td><strong>\u30b9\u30c6\u30c3\u30d72<\/strong><\/td><td>\u6b21\u306e\u65e5\u306e\u30c7\u30fc\u30bf\u304c\u51fa\u3066\u304f\u308b\u307e\u3067\u3001\u9023\u7d9a\u3057\u3066\u30c7\u30fc\u30bf\u3092\u62fe\u3046<\/td><\/tr><tr><td><strong>\u7d50\u679c<\/strong><\/td><td><strong>\u5fc5\u8981\u306a\u884c\u3060\u3051\u3057\u304b\u89e6\u3089\u306a\u3044<\/strong>\u306e\u3067\u7206\u901f<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">1. \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3068\u95a2\u6570\u306e\u95a2\u4fc2\uff08\u306a\u305c\u4f7f\u3048\u306a\u3044\u306e\u304b\uff09<\/h2>\n\n\n\n<p>\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306f\u3001\u3042\u3089\u304b\u3058\u3081\u7279\u5b9a\u306e\u5217\u3092\u300c\u4e26\u3073\u66ff\u3048\u3066\u4fdd\u5b58\u3057\u305f\u30ea\u30b9\u30c8\u300d\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u4f8b\u3048\u3070\u3001<code>created_at<\/code>\uff08\u767b\u9332\u65e5\uff09\u306b\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u304c\u3042\u308b\u5834\u5408\u3001DB\u5185\u3067\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u6574\u5217\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><td><strong>\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\uff08\u6574\u5217\u6e08\u307f\uff09<\/strong><\/td><td><strong>\u30dd\u30a4\u30f3\u30bf\uff08\u5b9f\u969b\u306e\u30c7\u30fc\u30bf\u306e\u5834\u6240\uff09<\/strong><\/td><\/tr><\/thead><tbody><tr><td>2023-10-01 10:00:00<\/td><td>[\u30c7\u30fc\u30bfA]<\/td><\/tr><tr><td>2023-10-01 15:00:00<\/td><td>[\u30c7\u30fc\u30bfB]<\/td><\/tr><tr><td>2023-10-02 09:00:00<\/td><td>[\u30c7\u30fc\u30bfC]<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">\u95a2\u6570\u3092\u4f7f\u3046\u3068\u3069\u3046\u306a\u308b\u304b\uff1f<\/h3>\n\n\n\n<p><code>WHERE TRUNC(created_at) = '2023-10-01'<\/code> \u3068\u66f8\u3044\u305f\u77ac\u9593\u3001DB\u306f\u3053\u3046\u8003\u3048\u307e\u3059\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\u300c\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306b\u306f\u300e10:00:00\u300f\u3068\u304b\u7d30\u304b\u3044\u6642\u9593\u304c\u5165\u3063\u3066\u3044\u308b\u306a\u2026\u3002\u3067\u3082\u30e6\u30fc\u30b6\u30fc\u306f\u300eTRUNC\uff08\u5207\u308a\u6368\u3066\uff09\u3057\u305f\u5f8c\u306e\u5024\u300f\u3067\u63a2\u305b\u3068\u8a00\u3063\u3066\u3044\u308b\u3002<strong>\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306e\u4e2d\u8eab\u3092\u5168\u90e8\u8a08\u7b97\u3057\u76f4\u3055\u306a\u3044\u3068\u3001\u3069\u308c\u304c\u4e00\u81f4\u3059\u308b\u304b\u5206\u304b\u3089\u306a\u3044\u305e\uff01<\/strong>\u300d<\/p>\n<\/blockquote>\n\n\n\n<p>\u7d50\u679c\u3068\u3057\u3066\u3001DB\u306f\u305b\u3063\u304b\u304f\u4e26\u3073\u66ff\u3048\u305f\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u4f7f\u308f\u305a\u306b\u3001\u30c6\u30fc\u30d6\u30eb\u306e\u7aef\u304b\u3089\u7aef\u307e\u3067\u5168\u90e8\u30c1\u30a7\u30c3\u30af\uff08\u30d5\u30eb\u30b9\u30ad\u30e3\u30f3\uff09\u3057\u59cb\u3081\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306e\u6b63\u4f53\u306f\u300c\u6574\u7406\u3055\u308c\u305f\u8f9e\u66f8\u300d \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3068\u306f\u3001\u672c\u306e\u5f8c\u308d\u306b\u3042\u308b\u7d22\u5f15\u3084\u8f9e\u66f8\u306e\u3088\u3046\u306b\u3001\u30c7\u30fc\u30bf\u304c\u7279\u5b9a\u306e\u9806\u756a\u3067\u4e26\u3093\u3067\u3044\u308b\u72b6\u614b\u3092\u6307\u3057\u307e\u3059\u3002 \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306f\u3053\u306e\u300c\u4e26\u3073\u9806\u300d\u3092\u5229\u7528\u3057\u3066\u3001\u300c2023-10-01\u300d\u3068\u3044\u3046\u30c7\u30fc<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jin_ogp_image_url":"","_jin_last_featured_id":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3246","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/posts\/3246","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/agile-software.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3246"}],"version-history":[{"count":1,"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/posts\/3246\/revisions"}],"predecessor-version":[{"id":3247,"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/posts\/3246\/revisions\/3247"}],"wp:attachment":[{"href":"https:\/\/agile-software.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3246"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/agile-software.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3246"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/agile-software.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3246"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}