{"id":5097,"date":"2025-07-16T20:25:52","date_gmt":"2025-07-16T11:25:52","guid":{"rendered":"https:\/\/sky-peace.net\/?p=5097"},"modified":"2025-07-16T20:25:52","modified_gmt":"2025-07-16T11:25:52","slug":"db-blank","status":"publish","type":"post","link":"https:\/\/sky-peace.net\/certified\/db-blank\/","title":{"rendered":"\u5fdc\u7528\u60c5\u5831SQL\u304c\u201c\u5f97\u70b9\u6e90\u201d\u306b\u5909\u308f\u308b\u601d\u8003\u6cd5\uff5c\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u7a7a\u6b04\u88dc\u5145\u554f\u984c\u3092\u8ad6\u7406\u3067\u89e3\u304d\u660e\u304b\u3059"},"content":{"rendered":"<p>\u306f\u3058\u3081\u306b\u3001\u3053\u306e\u8a18\u4e8b\u304c\u76ee\u6307\u3059\u30b4\u30fc\u30eb\u3092\u5171\u6709\u3055\u305b\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u3053\u306e\u8a18\u4e8b\u306f\u3001\u5358\u306a\u308bSQL\u69cb\u6587\u306e\u89e3\u8aac\u66f8\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u4e16\u306e\u4e2d\u306b\u306f\u7d20\u6674\u3089\u3057\u3044SQL\u306e\u5165\u9580\u66f8\u304c\u305f\u304f\u3055\u3093\u3042\u308a\u307e\u3059\u3057\u3001\u5404\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u5f79\u5272\u3092\u899a\u3048\u308b\u3053\u3068\u306f\u3082\u3061\u308d\u3093\u5927\u5207\u3067\u3059\u3002<\/p>\n<p>\u3057\u304b\u3057\u3001\u5fdc\u7528\u60c5\u5831\u6280\u8853\u8005\u8a66\u9a13\u3084\u9ad8\u5ea6IT\u8a66\u9a13\u306e\u300c\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u554f\u984c\u300d\u3067\u672c\u5f53\u306b\u6c42\u3081\u3089\u308c\u308b\u306e\u306f\u3001\u305d\u306e\u77e5\u8b58\u3092\u3044\u304b\u306b\u3057\u3066<strong>\u201c\u6b63\u89e3\u201d<\/strong>\u306b\u7d50\u3073\u3064\u3051\u308b\u304b\u3001\u3068\u3044\u3046\u5b9f\u8df5\u7684\u306a\u30b9\u30ad\u30eb\u3067\u3059\u3002<\/p>\n<p>\u7279\u306b\u3001\u591a\u304f\u306e\u53d7\u9a13\u8005\u304c\u6642\u9593\u3092\u6eb6\u304b\u3057\u3066\u3057\u307e\u3046SQL\u306e\u7a7a\u6b04\u88dc\u5145\u554f\u984c\u3002<\/p>\n<p>\u79c1\u305f\u3061\u306f\u3001\u3053\u306e\u554f\u984c\u3092\u5358\u306a\u308b\u6697\u8a18\u30b2\u30fc\u30e0\u3067\u306f\u306a\u304f\u3001<strong>\u300c\u554f\u984c\u6587\u306b\u6563\u308a\u3070\u3081\u3089\u308c\u305f\u30d2\u30f3\u30c8\u3092\u57fa\u306b\u3001\u7a7a\u6b04\u306b\u5165\u308b\u30d4\u30fc\u30b9\u3092\u8ad6\u7406\u7684\u306b\u898b\u3064\u3051\u51fa\u3059\u3001\u77e5\u7684\u306a\u30d1\u30ba\u30eb\u300d<\/strong>\u3060\u3068\u8003\u3048\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u3053\u3067\u3001\u3053\u306e\u8a18\u4e8b\u3067\u306f\u4ee5\u4e0b\u306e3\u3064\u3092\u3042\u306a\u305f\u306b\u63d0\u4f9b\u3059\u308b\u3053\u3068\u3092\u7d04\u675f\u3057\u307e\u3059\u3002<\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li><strong>\u30d1\u30bf\u30fc\u30f3\u5316\u3055\u308c\u305f\u300c\u89e3\u6cd5\u30c6\u30af\u30cb\u30c3\u30af\u300d<\/strong>\uff1a\u7a7a\u6b04\u306e\u201c\u5834\u6240\u201d\u3068\u201c\u524d\u5f8c\u306e\u6587\u8108\u201d\u304b\u3089\u3001\u6b63\u89e3\u5019\u88dc\u306e\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u77ac\u6642\u306b\u7d5e\u308a\u8fbc\u3080\u65b9\u6cd5\u3002<\/li>\n<li><strong>\u518d\u73fe\u6027\u306e\u3042\u308b\u300c\u601d\u8003\u30d7\u30ed\u30bb\u30b9\u300d<\/strong>\uff1a\u306a\u305c\u305d\u306e\u30ad\u30fc\u30ef\u30fc\u30c9\u304c\u6b63\u89e3\u306a\u306e\u304b\uff1f\u305d\u306e\u6839\u62e0\u3092\u8a00\u8a9e\u5316\u3057\u3001\u521d\u898b\u306e\u554f\u984c\u306b\u3082\u5bfe\u5fdc\u3067\u304d\u308b\u5fdc\u7528\u529b\u3092\u990a\u3046\u305f\u3081\u306e\u982d\u306e\u4f7f\u3044\u65b9\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>&#8211; <strong>\u5f97\u70b9\u6e90\u306b\u5909\u3048\u308b\u300c\u81ea\u4fe1\u300d<\/strong>\uff1aSQL\u554f\u984c\u3078\u306e\u82e6\u624b\u610f\u8b58\u3092\u514b\u670d\u3057\u3001\u300c\u3088\u3057\u3001\u6765\u305f\uff01\u300d\u3068\u697d\u3057\u3081\u308b\u3088\u3046\u306b\u306a\u308b\u305f\u3081\u306e\u30de\u30a4\u30f3\u30c9\u30bb\u30c3\u30c8\u3002<\/p>\n<p>\u3053\u306e\u8a18\u4e8b\u3092\u8aad\u307f\u7d42\u3048\u308b\u9803\u3001\u3042\u306a\u305f\u306fSQL\u306e\u7a7a\u6b04\u3092\u524d\u306b\u3057\u3066\u95c7\u96f2\u306b\u60a9\u3080\u3053\u3068\u306f\u306a\u304f\u306a\u308b\u3067\u3057\u3087\u3046\u3002<br \/>\n\u4ee3\u308f\u308a\u306b\u3001\u540d\u63a2\u5075\u306e\u3088\u3046\u306b\u8ad6\u7406\u306e\u7cf8\u3092\u305f\u3050\u308a\u5bc4\u305b\u3001\u30d1\u30ba\u30eb\u306e\u6700\u5f8c\u306e1\u30d4\u30fc\u30b9\u3092\u306f\u3081\u308b\u3088\u3046\u306b\u3001\u78ba\u4fe1\u3092\u3082\u3063\u3066\u7b54\u3048\u3092\u5c0e\u304d\u51fa\u305b\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u306f\u305a\u3067\u3059\u3002<\/p>\n<p>\u3055\u3042\u3001\u4e00\u7dd2\u306bSQL\u30d1\u30ba\u30eb\u3092\u89e3\u304d\u660e\u304b\u3059\u305f\u3081\u306e\u300c\u601d\u8003\u6cd5\u300d\u3092\u30de\u30b9\u30bf\u30fc\u3057\u3066\u3044\u304d\u307e\u3057\u3087\u3046\uff01<\/p>\n<h3>1. \u30a4\u30f3\u30c8\u30ed\u30c0\u30af\u30b7\u30e7\u30f3\uff1a\u305d\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u554f\u984c\u3001&#8221;\u5b9d\u306e\u5c71&#8221;\u304b\u3082\u3057\u308c\u307e\u305b\u3093<\/h3>\n<p>\u5fdc\u7528\u60c5\u5831\u6280\u8853\u8005\u8a66\u9a13\u3001\u5348\u5f8c\u554f\u984c\u3002\u3069\u306e\u5206\u91ce\u3092\u9078\u629e\u3059\u308b\u304b\u306f\u3001\u5408\u5426\u3092\u5206\u3051\u308b\u5927\u304d\u306a\u6226\u7565\u306e\u4e00\u3064\u3067\u3059\u3088\u306d\u3002<\/p>\n<p>\u305d\u306e\u4e2d\u3067\u3082\u300c\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u300d\u306f\u3001\u591a\u304f\u306e\u53c2\u8003\u66f8\u3067<strong>\u201c\u5b89\u5b9a\u629e\u201d<\/strong>\u3068\u3057\u3066\u7d39\u4ecb\u3055\u308c\u307e\u3059\u3002\u306a\u305c\u306a\u3089\u3001\u51fa\u984c\u3055\u308c\u308b\u30c6\u30fc\u30de\u3084\u5f62\u5f0f\u304c\u3042\u308b\u7a0b\u5ea6\u6c7a\u307e\u3063\u3066\u304a\u308a\u3001\u5bfe\u7b56\u3059\u308c\u3070\u7740\u5b9f\u306b\u30b9\u30b3\u30a2\u3092\u7a4d\u307f\u4e0a\u3052\u3089\u308c\u308b\u304b\u3089\u3067\u3059\u3002<\/p>\n<p>\u2026\u3057\u304b\u3057\u3001\u73fe\u5b9f\u306f\u3069\u3046\u3067\u3057\u3087\u3046\u304b\uff1f<\/p>\n<p>\u300cE-R\u56f3\u306f\u306a\u3093\u3068\u306a\u304f\u308f\u304b\u308b\u3051\u3069\u3001SQL\u306e\u9577\u3044\u30af\u30a8\u30ea\u3092\u898b\u308b\u3068\u982d\u304c\u771f\u3063\u767d\u306b\u306a\u308b\u2026\u300d<br \/>\n\u300cJOIN\u3084\u526f\u554f\u5408\u305b\u304c\u7d61\u3080\u3068\u3001\u3082\u3046\u4f55\u304c\u4f55\u3060\u304b\u2026\u300d<br \/>\n\u300c\u7d50\u5c40\u3001\u7a7a\u6b04\u88dc\u5145\u306f\u201c\u52d8\u201d\u3067\u57cb\u3081\u3066\u3057\u307e\u3063\u3066\u3044\u308b\u300d<\/p>\n<p>\u305d\u3093\u306a\u7d4c\u9a13\u306f\u3042\u308a\u307e\u305b\u3093\u304b\uff1f<br \/>\n\u201c\u5b89\u5b9a\u629e\u201d\u306e\u306f\u305a\u304c\u3001\u6c17\u3065\u3051\u3070\u201c\u9b3c\u9580\u201d\u306b\u306a\u3063\u3066\u3044\u308b\u3002\u305d\u306e\u6700\u5927\u306e\u539f\u56e0\u3053\u305d\u3001<strong>SQL\u306e\u7a7a\u6b04\u88dc\u5145\u554f\u984c<\/strong>\u3067\u3059\u3002<\/p>\n<p>\u3067\u3059\u304c\u3001\u3082\u3057\u2026\u3002<\/p>\n<p>\u3053\u306e&#8221;\u304a\u6c7a\u307e\u308a\u306e&#8221;SQL\u554f\u984c\u306b\u3001<strong>\u201c\u304a\u6c7a\u307e\u308a\u306e\u89e3\u6cd5\u30d1\u30bf\u30fc\u30f3\u201d<\/strong>\u304c\u3042\u3063\u305f\u3068\u3057\u305f\u3089\u3001\u3069\u3046\u3067\u3057\u3087\u3046\uff1f<\/p>\n<p>\u5b9f\u306f\u3001\u3042\u308b\u3093\u3067\u3059\u3002SQL\u306e\u7a7a\u6b04\u88dc\u5145\u554f\u984c\u306f\u3001\u554f\u984c\u6587\u306e\u69cb\u6210\u3084\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u914d\u7f6e\u306b\u4e00\u5b9a\u306e\u300c\u30af\u30bb\u300d\u304c\u3042\u308a\u307e\u3059\u3002\u305d\u306e\u300c\u30af\u30bb\u300d\u3092\u898b\u629c\u304f\u773c\u3055\u3048\u990a\u3048\u3070\u3001\u8907\u96d1\u306b\u898b\u3048\u308b\u30af\u30a8\u30ea\u3082\u3001\u9a5a\u304f\u307b\u3069\u30b7\u30f3\u30d7\u30eb\u306b\u89e3\u304d\u660e\u304b\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001\u305d\u306e\u300c\u30af\u30bb\u300d\u3092\u898b\u629c\u304f\u305f\u3081\u306e\u601d\u8003\u6cd5\u3092\u3001\u3042\u306a\u305f\u306b\u4f1d\u6388\u3057\u307e\u3059\u3002<br \/>\n\u3082\u3046\u201c\u52d8\u201d\u306b\u983c\u308b\u5fc5\u8981\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u8ad6\u7406\u7684\u306a\u6839\u62e0\u3092\u3082\u3063\u3066\u3001\u81ea\u4fe1\u3092\u6301\u3063\u3066\u89e3\u7b54\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u3087\u3046\u3002\u3042\u306a\u305f\u306e\u201c\u9b3c\u9580\u201d\u3092\u201c\u5b9d\u306e\u5c71\u201d\u306b\u5909\u3048\u308b\u65c5\u3078\u3001\u3044\u3056\u51fa\u767a\u3067\u3059\uff01<\/p>\n<h3>2. \u7d50\u8ad6\u30d5\u30a1\u30fc\u30b9\u30c8\uff1aSQL\u7a7a\u6b04\u88dc\u5145\u306f\u300c\u5834\u6240\u300d\u3068\u300c\u6587\u8108\u300d\u306e\u30d1\u30bf\u30fc\u30f3\u8a8d\u8b58\u30b2\u30fc\u30e0\u3060<\/h3>\n<p><img decoding=\"async\" class=\"alignnone wp-image-5101 size-large\" src=\"https:\/\/sky-peace.net\/certified\/wp-content\/uploads\/2025\/07\/Gemini_Generated_Image_yujoxwyujoxwyujo-1024x559.png\" alt=\"\" width=\"920\" height=\"502\" \/><\/p>\n<p>\u3067\u306f\u3001SQL\u306e\u7a7a\u6b04\u88dc\u5145\u554f\u984c\u3092\u653b\u7565\u3059\u308b\u6838\u5fc3\u3092\u3001\u5358\u5200\u76f4\u5165\u306b\u304a\u4f1d\u3048\u3057\u307e\u3059\u3002<\/p>\n<p>\u305d\u308c\u306f\u3001<\/p>\n<p><strong>\u30ad\u30fc\u30ef\u30fc\u30c9\u304c\u5165\u308b\u300c\u5834\u6240\u300d\uff08\u3069\u306e\u53e5\u306e\u7a7a\u6b04\u304b\uff09\u3068\u3001<br \/>\n\u305d\u306e\u300c\u524d\u5f8c\u306e\u6587\u8108\u300d\u304c\u6301\u3064\u201c\u5fc5\u51fa\u30d1\u30bf\u30fc\u30f3\u201d\u3092\u63b4\u3080\u3053\u3068\u3002<\/strong><\/p>\n<p>\u3053\u308c\u306b\u5c3d\u304d\u307e\u3059\u3002<\/p>\n<p>\u3069\u3046\u3044\u3046\u3053\u3068\u304b\uff1f<br \/>\n\u4f8b\u3048\u3070\u3001\u3042\u306a\u305f\u304c\u30df\u30b9\u30c6\u30ea\u30fc\u5c0f\u8aac\u3092\u8aad\u3093\u3067\u3044\u308b\u3068\u3057\u307e\u3059\u3002\u3082\u3057\u300c\u72af\u4eba\u306f\u3001\u88ab\u5bb3\u8005\u306e\u3059\u3050\u96a3\u306b\u4f4f\u3093\u3067\u3044\u305f______\u3060\u300d\u3068\u3044\u3046\u4e00\u6587\u304c\u3042\u308c\u3070\u3001\u7a7a\u6b04\u306b\u306f\u300c\u4eba\u7269\u300d\u3084\u300c\u96a3\u4eba\u300d\u3068\u3044\u3063\u305f\u8a00\u8449\u304c\u5165\u308b\u3068\u3001\u307b\u307c\u78ba\u4fe1\u3067\u304d\u307e\u3059\u3088\u306d\u3002\u307e\u3055\u304b\u300c\u72ac\u300d\u3084\u300c\u673a\u300d\u304c\u5165\u308b\u3068\u306f\u601d\u308f\u306a\u3044\u306f\u305a\u3067\u3059\u3002<\/p>\n<p>SQL\u306e\u7a7a\u6b04\u88dc\u5145\u3082\u3001\u3053\u308c\u3068\u5168\u304f\u540c\u3058\u3067\u3059\u3002<\/p>\n<ul>\n<li><code>GROUP BY<\/code>\u53e5\u306e\u5f8c\u308d\u306e\u7a7a\u6b04\u306b\u306f\u3001\u307b\u307c\u9593\u9055\u3044\u306a\u304f\u300c\u30b0\u30eb\u30fc\u30d7\u5316\u306e\u30ad\u30fc\u3068\u306a\u308b\u5217\u540d\u300d\u304c\u5165\u308b\u3002<\/li>\n<li><code>WHERE<\/code>\u53e5\u3067\u7d5e\u308a\u8fbc\u3093\u3060\u7d50\u679c\u3092\u3001\u3055\u3089\u306b\u30b0\u30eb\u30fc\u30d7\u5358\u4f4d\u3067\u7d5e\u308a\u8fbc\u3080\u6587\u8108\u306a\u3089\u3001<code>HAVING<\/code>\u53e5\u306e\u51fa\u756a\u3002<\/li>\n<li>\u8907\u6570\u306e\u8868\u3092\u300c\u3064\u306a\u3050\u300d\u3068\u3044\u3046\u6587\u8108\u306a\u3089\u3001<code>JOIN<\/code>\u304c\u767b\u5834\u3057\u3001\u305d\u306e\u76f4\u5f8c\u306e<code>ON<\/code>\u53e5\u306e\u7a7a\u6b04\u306b\u306f\u300c\u4e21\u65b9\u306e\u8868\u306b\u5171\u901a\u3059\u308b\u5217\uff08\u30ad\u30fc\uff09\u300d\u304c\u5165\u308b\u3002<\/li>\n<\/ul>\n<p>\u3053\u306e\u3088\u3046\u306b\u3001\u7a7a\u6b04\u304c\u3069\u306e\u300c\u5834\u6240\u300d\u306b\u3042\u308a\u3001\u3069\u3093\u306a\u300c\u6587\u8108\u300d\u3067\u4f7f\u308f\u308c\u3066\u3044\u308b\u304b\u3092\u898b\u629c\u3051\u3070\u3001\u6b63\u89e3\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u5019\u88dc\u306f\u5287\u7684\u306b\u7d5e\u3089\u308c\u307e\u3059\u3002<\/p>\n<p>\u3064\u307e\u308a\u3001\u95c7\u96f2\u306b\u5168\u3066\u306eSQL\u69cb\u6587\u3092\u601d\u3044\u51fa\u3059\u306e\u3067\u306f\u306a\u304f\u3001<strong>\u6b63\u89e3\u306e\u300c\u78ba\u7387\u300d\u304c\u9ad8\u3044\u30ad\u30fc\u30ef\u30fc\u30c9\u304b\u3089\u5f53\u3066\u306f\u3081\u3066\u3044\u304f\u601d\u8003\u6cd5<\/strong>\u3053\u305d\u304c\u3001\u6700\u77ed\u30fb\u6700\u5f37\u306e\u653b\u7565\u30eb\u30fc\u30c8\u306a\u306e\u3067\u3059\u3002<\/p>\n<p>\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u304b\u3089\u3001\u3053\u306e\u300c\u5fc5\u51fa\u30d1\u30bf\u30fc\u30f3\u300d\u3092\u4e00\u3064\u3072\u3068\u3064\u3001\u5fb9\u5e95\u7684\u306b\u89e3\u304d\u660e\u304b\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<h3>3. \u5927\u56f3\u89e3\uff1aSQL\u30af\u30a8\u30ea\u306f&#8221;\u3053\u306e\u9806\u756a&#8221;\u3067\u51e6\u7406\u3055\u308c\u308b\uff01\u6226\u5834\u30de\u30c3\u30d7\u3092\u624b\u306b\u5165\u308c\u3088<\/h3>\n<p>\u8907\u96d1\u306b\u898b\u3048\u308bSQL\u6587\u3082\u3001\u5b9f\u306f\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u5185\u90e8\u3067\u306f<strong>\u53b3\u683c\u306a\u30eb\u30fc\u30eb\uff08\u51e6\u7406\u9806\u5e8f\uff09<\/strong>\u306b\u5f93\u3063\u3066\u52d5\u3044\u3066\u3044\u307e\u3059\u3002\u79c1\u305f\u3061\u304c\u66f8\u304f\u9806\u756a\uff08<code>SELECT<\/code>\u304c\u6700\u521d\uff09\u3068\u3001\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u304c\u89e3\u91c8\u3059\u308b\u9806\u756a\u306f\u9055\u3046\u3001\u3068\u3044\u3046\u70b9\u304c\u975e\u5e38\u306b\u91cd\u8981\u3067\u3059\u3002<\/p>\n<p>\u3053\u306e\u300c\u8ad6\u7406\u7684\u306a\u51e6\u7406\u9806\u5e8f\u300d\u3053\u305d\u3001SQL\u7a7a\u6b04\u88dc\u5145\u554f\u984c\u3092\u89e3\u304f\u305f\u3081\u306e&#8221;\u6226\u5834\u30de\u30c3\u30d7&#8221;\u3068\u306a\u308a\u307e\u3059\u3002\u307e\u305a\u306f\u3053\u306e\u30de\u30c3\u30d7\u3092\u624b\u306b\u5165\u308c\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><strong>\u3010SQL\u30af\u30a8\u30ea\u306e\u8ad6\u7406\u7684\u306a\u51e6\u7406\u9806\u5e8f\u30de\u30c3\u30d7\u3011<\/strong><\/p>\n<p>\uff08\u2193\u3053\u3053\u306b\u672c\u6765\u306f\u56f3\u304c\u5165\u308b\u30a4\u30e1\u30fc\u30b8\u3067\u3059\uff09<\/p>\n<div style=\"border: 2px solid #4a90e2; padding: 15px; border-radius: 8px; background-color: #f4f8ff;\">\n<p><strong>\u30b9\u30c6\u30c3\u30d71\uff1aFROM \/ JOIN<\/strong><br \/>\n\u307e\u305a\u3001\u3069\u306e\u30c6\u30fc\u30d6\u30eb\uff08\u53f0\u5e33\uff09\u304b\u3089\u30c7\u30fc\u30bf\u3092\u53d6\u3063\u3066\u304f\u308b\u304b\u3092\u6c7a\u5b9a\u3057\u307e\u3059\u3002\u8907\u6570\u306e\u30c6\u30fc\u30d6\u30eb\u304c\u3042\u308b\u5834\u5408\u306f\u3001\u3053\u3053\u3067\u3059\u3079\u3066\u7d50\u5408\uff08JOIN\uff09\u3057\u3066\u3001\u4e00\u679a\u306e\u5de8\u5927\u306a\u4eee\u60f3\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<br \/>\n&#x27a1;&#xfe0f; <em>(\u601d\u8003\u30dd\u30a4\u30f3\u30c8\uff1a\u3053\u3053\u3067\u306e\u7a7a\u6b04\u306f\u300c\u3069\u306e\u30c6\u30fc\u30d6\u30eb\u3068\u3001\u3069\u306e\u30ad\u30fc\u3067\u7d50\u5408\u3059\u308b\u304b\u300d\u304c\u554f\u308f\u308c\u308b)<\/em><\/p>\n<hr \/>\n<p><strong>\u30b9\u30c6\u30c3\u30d72\uff1aWHERE<\/strong><br \/>\n\u30b9\u30c6\u30c3\u30d71\u3067\u4f5c\u3063\u305f\u5de8\u5927\u306a\u30c6\u30fc\u30d6\u30eb\u304b\u3089\u3001\u300c\u6761\u4ef6\u306b\u5408\u3046\u884c\u3060\u3051\u300d\u3092\u7d5e\u308a\u8fbc\u307f\u307e\u3059\u3002\u3053\u3053\u3067\u306f\u307e\u3060\u30b0\u30eb\u30fc\u30d7\u3068\u3044\u3046\u6982\u5ff5\u306f\u306a\u304f\u3001\u4e00\u884c\u4e00\u884c\u3092\u500b\u5225\u5be9\u67fb\u3059\u308b\u30a4\u30e1\u30fc\u30b8\u3067\u3059\u3002<br \/>\n&#x27a1;&#xfe0f; <em>(\u601d\u8003\u30dd\u30a4\u30f3\u30c8\uff1a\u500b\u4eba(\u884c)\u5358\u4f4d\u306e\u6761\u4ef6\u5206\u5c90\u3002\u526f\u554f\u5408\u305b(IN, EXISTS)\u304c\u983b\u51fa\uff01)<\/em><\/p>\n<hr \/>\n<p><strong>\u30b9\u30c6\u30c3\u30d73\uff1aGROUP BY<\/strong><br \/>\n\u30b9\u30c6\u30c3\u30d72\u3067\u7d5e\u308a\u8fbc\u3093\u3060\u884c\u305f\u3061\u3092\u3001\u6307\u5b9a\u3057\u305f\u30ad\u30fc\uff08\u4f8b\uff1a\u90e8\u9580\u3054\u3068\u3001\u5546\u54c1\u30ab\u30c6\u30b4\u30ea\u3054\u3068\uff09\u3067\u30b0\u30eb\u30fc\u30d7\u5206\u3051\u3057\u307e\u3059\u3002\u3053\u3053\u304b\u3089\u96c6\u8a08\u4f5c\u696d\u306e\u6e96\u5099\u306b\u5165\u308a\u307e\u3059\u3002<br \/>\n&#x27a1;&#xfe0f; <em>(\u601d\u8003\u30dd\u30a4\u30f3\u30c8\uff1a\u96c6\u8a08\u306e\u201c\u8ef8\u201d\u3092\u6307\u5b9a\u3059\u308b\u5834\u6240\u3002SELECT\u53e5\u306b\u96c6\u7d04\u95a2\u6570\u304c\u3042\u308c\u3070\u3001\u307e\u305a\u3053\u3053\u3092\u7591\u3046)<\/em><\/p>\n<hr \/>\n<p><strong>\u30b9\u30c6\u30c3\u30d74\uff1aHAVING<\/strong><br \/>\n\u30b9\u30c6\u30c3\u30d73\u3067\u4f5c\u6210\u3057\u305f\u30b0\u30eb\u30fc\u30d7\u306b\u5bfe\u3057\u3066\u3001\u300c\u6761\u4ef6\u306b\u5408\u3046\u30b0\u30eb\u30fc\u30d7\u3060\u3051\u300d\u3092\u7d5e\u308a\u8fbc\u307f\u307e\u3059\u3002<code>WHERE<\/code>\u304c\u201c\u500b\u4eba\u6226\u201d\u306a\u3089\u3001<code>HAVING<\/code>\u306f\u201c\u56e3\u4f53\u6226\u201d\u306e\u30d5\u30a3\u30eb\u30bf\u30fc\u3067\u3059\u3002<br \/>\n&#x27a1;&#xfe0f; <em>(\u601d\u8003\u30dd\u30a4\u30f3\u30c8\uff1a\u5fc5\u305aGROUP BY\u3068\u30bb\u30c3\u30c8\u3067\u767b\u5834\u3002\u96c6\u7d04\u95a2\u6570(COUNT, SUM\u7b49)\u3092\u4f7f\u3063\u305f\u6761\u4ef6\u304c\u5165\u308b)<\/em><\/p>\n<hr \/>\n<p><strong>\u30b9\u30c6\u30c3\u30d75\uff1aSELECT<\/strong><br \/>\n\u30b9\u30c6\u30c3\u30d74\u3067\u751f\u304d\u6b8b\u3063\u305f\u30b0\u30eb\u30fc\u30d7\u304b\u3089\u3001\u6700\u7d42\u7684\u306b\u3069\u306e\u5217\u3092\u8868\u793a\u3059\u308b\u304b\u3092\u6c7a\u5b9a\u3057\u307e\u3059\u3002\u96c6\u7d04\u95a2\u6570\uff08<code>COUNT<\/code>, <code>SUM<\/code>\u306a\u3069\uff09\u306b\u3088\u308b\u8a08\u7b97\u3082\u3053\u3053\u3067\u884c\u308f\u308c\u307e\u3059\u3002<br \/>\n&#x27a1;&#xfe0f; <em>(\u601d\u8003\u30dd\u30a4\u30f3\u30c8\uff1a\u6700\u7d42\u7684\u306a\u30a2\u30a6\u30c8\u30d7\u30c3\u30c8\u3092\u6c7a\u3081\u308b\u5834\u6240\u3002CASE\u5f0f\u306b\u3088\u308b\u6761\u4ef6\u5206\u5c90\u3082\u72d9\u308f\u308c\u308b)<\/em><\/p>\n<hr \/>\n<p><strong>\u30b9\u30c6\u30c3\u30d76\uff1aORDER BY<\/strong><br \/>\n\u6700\u7d42\u7d50\u679c\u3092\u3001\u6307\u5b9a\u3057\u305f\u5217\u3092\u57fa\u6e96\u306b\u4e26\u3079\u66ff\u3048\u307e\u3059\u3002\u3059\u3079\u3066\u306e\u51e6\u7406\u304c\u7d42\u308f\u3063\u305f\u5f8c\u306e\u3001\u6700\u5f8c\u306e\u5473\u4ed8\u3051\u3067\u3059\u3002<br \/>\n&#x27a1;&#xfe0f; <em>(\u601d\u8003\u30dd\u30a4\u30f3\u30c8\uff1a\u4e26\u3073\u9806\u306e\u6307\u5b9a\u3002ASC(\u6607\u9806)\u304bDESC(\u964d\u9806)\u304b)<\/em><\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<p>\u3044\u304b\u304c\u3067\u3057\u3087\u3046\u304b\uff1f\u3053\u306e<strong>\u300cFROM \u2192 WHERE \u2192 GROUP BY \u2192 HAVING \u2192 SELECT \u2192 ORDER BY\u300d<\/strong>\u3068\u3044\u3046\u6d41\u308c\u3092\u982d\u306b\u5165\u308c\u3066\u304a\u304f\u3060\u3051\u3067\u3001SQL\u6587\u306e\u898b\u901a\u3057\u304c\u5287\u7684\u306b\u826f\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u30de\u30c3\u30d7\u306e\u3069\u3053\u306b\u7a7a\u6b04\u304c\u3042\u308b\u306e\u304b\uff1f\u305d\u308c\u306b\u3088\u3063\u3066\u3001\u5165\u308b\u3079\u304d\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u5019\u88dc\u306f\u81ea\u305a\u3068\u898b\u3048\u3066\u304f\u308b\u306e\u3067\u3059\u3002\u6b21\u306e\u7ae0\u304b\u3089\u3001\u5404\u30b9\u30c6\u30c3\u30d7\u3067\u72d9\u308f\u308c\u308b\u7a7a\u6b04\u306e\u30d1\u30bf\u30fc\u30f3\u3092\u5177\u4f53\u7684\u306b\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<h3>4. \u306a\u305c\uff1f\u304c\u308f\u304b\u308b\u6df1\u6398\u308a\u89e3\u8aac\uff1a\u983b\u51fa&#8221;\u7a7a\u6b04&#8221;\u30d1\u30bf\u30fc\u30f3\u5225 \u601d\u8003\u30c8\u30ec\u30fc\u30b9<\/h3>\n<h4>4-1. \u3010\u5834\u6240\uff1aFROM \/ JOIN\u53e5\u3011 \u3059\u3079\u3066\u306e\u30c7\u30fc\u30bf\u306e\u51fa\u767a\u70b9<\/h4>\n<p><code>FROM<\/code>\u53e5\u306f\u3001\u30af\u30a8\u30ea\u304c\u3069\u306e\u30c6\u30fc\u30d6\u30eb\u3092\u6271\u3046\u304b\u3092\u5ba3\u8a00\u3059\u308b\u3001\u3044\u308f\u3070\u300c\u98df\u6750\u9078\u3073\u300d\u306e\u30b9\u30c6\u30c3\u30d7\u3067\u3059\u3002\u3053\u3053\u306e\u7a7a\u6b04\u306f\u3001\u57fa\u672c\u304b\u3089\u5fdc\u7528\u307e\u3067\u69d8\u3005\u306a\u30d1\u30bf\u30fc\u30f3\u304c\u8003\u3048\u3089\u308c\u307e\u3059\u3002<\/p>\n<h5>\u601d\u8003\u30d1\u30bf\u30fc\u30f3\u2460\uff1a\u30c6\u30fc\u30d6\u30eb\u306f\u4e00\u3064\u304b\uff1f\u8907\u6570\u304b\uff1f<\/h5>\n<p>\u307e\u305a\u6700\u521d\u306b\u8003\u3048\u308b\u3079\u304d\u306f\u3001\u30af\u30a8\u30ea\u304c\u6271\u3063\u3066\u3044\u308b\u30c6\u30fc\u30d6\u30eb\u306e\u6570\u3067\u3059\u3002<\/p>\n<ul>\n<li><strong>\u30c6\u30fc\u30d6\u30eb\u304c1\u3064 \u2192 <\/strong>\u7a7a\u6b04\u306b\u306f\u5358\u7d14\u306b<strong>\u30c6\u30fc\u30d6\u30eb\u540d<\/strong>\u304c\u5165\u308a\u307e\u3059\u3002\u3053\u308c\u306f\u6700\u3082\u57fa\u672c\u7684\u306a\u5f62\u3067\u3059\u3002<\/li>\n<li><strong>\u30c6\u30fc\u30d6\u30eb\u304c2\u3064\u4ee5\u4e0a \u2192 <\/strong>\u307b\u307c\u78ba\u5b9f\u306b<strong><code>JOIN<\/code><\/strong>\u30ad\u30fc\u30ef\u30fc\u30c9\u304c\u767b\u5834\u3057\u307e\u3059\u3002\u5fdc\u7528\u60c5\u5831\u3067\u554f\u308f\u308c\u308b\u306e\u306f\u3053\u306e\u30d1\u30bf\u30fc\u30f3\u3067\u3059\u3002<\/li>\n<\/ul>\n<h5>\u601d\u8003\u30d1\u30bf\u30fc\u30f3\u2461\uff1a\u300c\u3069\u306eJOIN\u3092\u4f7f\u3046\u304b\uff1f\u300d\u3092\u6587\u8108\u304b\u3089\u898b\u629c\u304f<\/h5>\n<p><code>JOIN<\/code>\u304c\u5fc5\u8981\u3060\u3068\u5224\u65ad\u3057\u305f\u3089\u3001\u6b21\u306f\u305d\u306e\u7a2e\u985e\u3092\u8003\u3048\u307e\u3059\u3002\u5fdc\u7528\u60c5\u5831\u3067\u7279\u306b\u91cd\u8981\u306a\u306e\u306f<code>INNER JOIN<\/code>\u3068<code>LEFT JOIN<\/code>\uff08\u307e\u305f\u306f<code>LEFT OUTER JOIN<\/code>\uff09\u306e\u4f7f\u3044\u5206\u3051\u3067\u3059\u3002<\/p>\n<p><strong>\u4f8b\uff1a\u793e\u54e1\u30c6\u30fc\u30d6\u30eb \u3068 \u90e8\u7f72\u30c6\u30fc\u30d6\u30eb<\/strong><\/p>\n<div style=\"display: flex; justify-content: space-around; margin-bottom: 15px;\">\n<div style=\"width: 45%;\"><strong>\u3010INNER JOIN (\u5185\u90e8\u7d50\u5408)\u3011<\/strong><br \/>\n\u300c\u4e21\u65b9\u306e\u30c6\u30fc\u30d6\u30eb\u306b\u5b58\u5728\u3059\u308b\u30c7\u30fc\u30bf<strong>\u3060\u3051<\/strong>\u3092\u53d6\u308a\u51fa\u3059\u300d\u7d50\u5408\u3067\u3059\u3002<br \/>\n<strong>\u6587\u8108\uff1a<\/strong>\u300c\u90e8\u7f72\u306b\u6240\u5c5e\u3057\u3066\u3044\u308b\u793e\u54e1\u306e\u4e00\u89a7\u300d\u300c\u5546\u54c1\u3092\u8cfc\u5165\u3057\u305f\u3053\u3068\u304c\u3042\u308b\u9867\u5ba2\u30ea\u30b9\u30c8\u300d\u306a\u3069\u3001\u95a2\u9023\u304c\u660e\u78ba\u306a\u30c7\u30fc\u30bf\u3060\u3051\u304c\u6b32\u3057\u3044\u5834\u5408\u306b\u4f7f\u308f\u308c\u307e\u3059\u3002<br \/>\n<strong>SQL\u4f8b\uff1a<\/strong><code>... FROM \u793e\u54e1\u30c6\u30fc\u30d6\u30eb a <strong>INNER JOIN<\/strong> \u90e8\u7f72\u30c6\u30fc\u30d6\u30eb b ON a.\u90e8\u7f72\u30b3\u30fc\u30c9 = b.\u90e8\u7f72\u30b3\u30fc\u30c9<\/code><\/div>\n<div style=\"width: 45%;\"><strong>\u3010LEFT JOIN (\u5de6\u5916\u90e8\u7d50\u5408)\u3011<\/strong><br \/>\n\u300c\u5de6\u5074\u306e\u30c6\u30fc\u30d6\u30eb\u306e\u5168\u30c7\u30fc\u30bf\u3068\u3001\u305d\u308c\u306b\u7d10\u3065\u304f\u53f3\u5074\u306e\u30c6\u30fc\u30d6\u30eb\u306e\u30c7\u30fc\u30bf\u300d\u3092\u53d6\u308a\u51fa\u3057\u307e\u3059\u3002\u53f3\u5074\u306b\u7d10\u3065\u304f\u30c7\u30fc\u30bf\u304c\u306a\u3051\u308c\u3070<code>NULL<\/code>\u304c\u5165\u308a\u307e\u3059\u3002<br \/>\n<strong>\u6587\u8108\uff1a<\/strong>\u300c<strong>\u3059\u3079\u3066\u306e<\/strong>\u793e\u54e1\u306e\u90e8\u7f72\u540d\uff08\u90e8\u7f72\u672a\u6240\u5c5e\u306e\u793e\u54e1\u3082\u542b\u3080\uff09\u300d\u300c<strong>\u3059\u3079\u3066\u306e<\/strong>\u5546\u54c1\u306e\u58f2\u4e0a\uff08\u4e00\u5ea6\u3082\u58f2\u308c\u3066\u3044\u306a\u3044\u5546\u54c1\u3082\u542b\u3080\uff09\u300d\u306a\u3069\u3001<strong>\u30de\u30b9\u30bf\u30fc\u5074\u306e\u30c7\u30fc\u30bf\u3092\u8ef8\u306b<\/strong>\u60c5\u5831\u3092\u898b\u305f\u3044\u5834\u5408\u306b\u4f7f\u308f\u308c\u307e\u3059\u3002<br \/>\n<strong>SQL\u4f8b\uff1a<\/strong><code>... FROM \u793e\u54e1\u30c6\u30fc\u30d6\u30eb a <strong>LEFT JOIN<\/strong> \u90e8\u7f72\u30c6\u30fc\u30d6\u30eb b ON a.\u90e8\u7f72\u30b3\u30fc\u30c9 = b.\u90e8\u7f72\u30b3\u30fc\u30c9<\/code><\/div>\n<\/div>\n<p>\u7a7a\u6b04\u304c<code>JOIN<\/code>\u306e\u524d\u5f8c\u306b\u3042\u308c\u3070\u3001\u554f\u984c\u6587\u306e\u300c\uff5e\u3082\u542b\u3080\u300d\u300c\uff5e\u304c\u306a\u3044\u3082\u306e\u3082\u8868\u793a\u300d\u3068\u3044\u3063\u305f\u8868\u73fe\u304c\u3001<code>LEFT JOIN<\/code>\u3092\u9078\u629e\u3059\u308b\u5f37\u529b\u306a\u30d2\u30f3\u30c8\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h5>\u601d\u8003\u30d1\u30bf\u30fc\u30f3\u2462\uff1aJOIN\u306e\u76f8\u68d2\u300cON\u300d\u3092\u7591\u3048<\/h5>\n<p><code>JOIN<\/code>\u30ad\u30fc\u30ef\u30fc\u30c9\u304c\u51fa\u3066\u304d\u305f\u3089\u3001\u305d\u306e\u76f4\u5f8c\u306b\u306f\u5fc5\u305a<strong><code>ON<\/code><\/strong>\u53e5\u304c\u7d9a\u304d\u307e\u3059\u3002<code>ON<\/code>\u53e5\u306e\u7a7a\u6b04\u3067\u554f\u308f\u308c\u308b\u306e\u306f\u3001100%<strong>\u300c\u30c6\u30fc\u30d6\u30eb\u540c\u58eb\u3092\u7e4b\u3050\u305f\u3081\u306e\u7d50\u5408\u30ad\u30fc\u300d<\/strong>\u3067\u3059\u3002<\/p>\n<p><code>... ON a.<strong>[ \u30a2 ]<\/strong> = b.<strong>[ \u30a4 ]<\/strong><\/code><\/p>\n<p>\u3053\u306e\u3088\u3046\u306a\u7a7a\u6b04\u304c\u3042\u3063\u305f\u3089\u3001E-R\u56f3\u3092\u898b\u3066\u30012\u3064\u306e\u30c6\u30fc\u30d6\u30eb\u3092\u95a2\u9023\u4ed8\u3051\u3066\u3044\u308b\u7dda\uff08\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\uff09\u306e\u4e21\u7aef\u306b\u3042\u308b\u5c5e\u6027\uff08\u5217\u540d\uff09\u3092\u63a2\u305b\u3070\u3001\u305d\u308c\u304c\u7b54\u3048\u3067\u3059\u3002\u4f8b\u3048\u3070\u300c\u793e\u54e1\u30c6\u30fc\u30d6\u30eb\u306e\u90e8\u7f72\u30b3\u30fc\u30c9\u300d\u3068\u300c\u90e8\u7f72\u30c6\u30fc\u30d6\u30eb\u306e\u90e8\u7f72\u30b3\u30fc\u30c9\u300d\u3068\u3044\u3063\u305f\u30da\u30a2\u3067\u3059\u306d\u3002<\/p>\n<h5>\u601d\u8003\u30d1\u30bf\u30fc\u30f3\u2463\uff1a\uff08\u5fdc\u7528\uff09FROM\u53e5\u306e\u4e2d\u306eSELECT\u6587<\/h5>\n<p>\u5c11\u3057\u8907\u96d1\u306a\u554f\u984c\u3067\u306f\u3001<code>FROM<\/code>\u53e5\u306e\u76f4\u5f8c\u306b\u30c6\u30fc\u30d6\u30eb\u540d\u3067\u306f\u306a\u304f\u3001\u62ec\u5f27<code>()<\/code>\u3067\u56f2\u307e\u308c\u305f<code>SELECT<\/code>\u6587\uff08<strong>\u526f\u554f\u3044\u5408\u308f\u305b<\/strong>\u307e\u305f\u306f<strong>\u5c0e\u51fa\u8868<\/strong>\u3068\u547c\u3070\u308c\u307e\u3059\uff09\u304c\u5165\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p><code>... FROM (SELECT ... FROM ... ) AS \u5225\u540d ...<\/code><\/p>\n<p>\u3053\u308c\u306f\u300c\u5148\u306b\u4e2d\u9593\u7684\u306a\u96c6\u8a08\u3084\u7d5e\u308a\u8fbc\u307f\u3092\u884c\u3063\u305f&#8221;\u4eee\u60f3\u7684\u306a\u30df\u30cb\u30c6\u30fc\u30d6\u30eb&#8221;\u3092\u305d\u306e\u5834\u3067\u4f5c\u308a\u3001\u305d\u308c\u3092\u4f7f\u3063\u3066\u3055\u3089\u306b\u51e6\u7406\u3092\u7d9a\u3051\u305f\u3044\u300d\u3068\u3044\u3046\u6587\u8108\u3067\u4f7f\u308f\u308c\u307e\u3059\u3002<code>GROUP BY<\/code>\u3057\u305f\u7d50\u679c\u3092\u3001\u3055\u3089\u306b\u5225\u306e\u30c6\u30fc\u30d6\u30eb\u3068<code>JOIN<\/code>\u3057\u305f\u3044\u5834\u5408\u306a\u3069\u304c\u5178\u578b\u4f8b\u3067\u3059\u3002<\/p>\n<p><code>FROM<\/code>\u53e5\u306e\u76f4\u5f8c\u304c\u7a7a\u6b04\u3067\u3001\u305d\u306e\u5f8c\u306b<code>AS<\/code>\u3084\u30c6\u30fc\u30d6\u30eb\u306e\u5225\u540d\u304c\u7d9a\u304f\u3088\u3046\u306a\u3089\u3001\u3053\u306e\u30d1\u30bf\u30fc\u30f3\u3092\u7591\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<h4>4-2. \u3010\u5834\u6240\uff1aWHERE\u53e5\u3011 \u30c7\u30fc\u30bf\u306e\u884c\u65b9\u3092\u6c7a\u3081\u308b\u6700\u521d\u306e\u95a2\u6240<\/h4>\n<p><code>WHERE<\/code>\u53e5\u306f\u3001<code>FROM<\/code>\u53e5\u3067\u4f5c\u3089\u308c\u305f\u5de8\u5927\u306a\u30c6\u30fc\u30d6\u30eb\u304b\u3089\u3001\u6761\u4ef6\u306b\u5408\u3046<strong>\u884c<\/strong>\u3092\u3075\u308b\u3044\u306b\u304b\u3051\u308b\u5f79\u5272\u3092\u6301\u3061\u307e\u3059\u3002\u3044\u308f\u3070\u300c\u500b\u4eba\u9762\u63a5\u300d\u306e\u30b9\u30c6\u30c3\u30d7\u3002\u3053\u3053\u3067\u306e\u7a7a\u6b04\u306f\u3001\u6761\u4ef6\u5f0f\u306e\u4f5c\u308a\u65b9\u304c\u554f\u308f\u308c\u307e\u3059\u3002<\/p>\n<h5>\u601d\u8003\u30d1\u30bf\u30fc\u30f3\u2460\uff1a\u5358\u7d14\u306a\u6761\u4ef6\u5f0f\uff08\u57fa\u672c\u306e\u30ad\uff09<\/h5>\n<p>\u307e\u305a\u306f\u57fa\u672c\u3067\u3059\u3002\u7a7a\u6b04\u304c\u300c\u5217\u540d \u3007 \u5024\u300d\u306e\u3088\u3046\u306a\u5f62\u306a\u3089\u3001\u6bd4\u8f03\u6f14\u7b97\u5b50\uff08<code>=, &lt;&gt;, &gt;, &lt;<\/code>\u306a\u3069\uff09\u3084\u3001\u7bc4\u56f2\u3092\u6307\u5b9a\u3059\u308b<code>BETWEEN<\/code>\u3001\u6587\u5b57\u5217\u306e\u90e8\u5206\u4e00\u81f4\u3092\u8abf\u3079\u308b<code>LIKE<\/code>\u304c\u5165\u308b\u53ef\u80fd\u6027\u304c\u9ad8\u3044\u3067\u3059\u3002\u3053\u308c\u306f\u30a6\u30a9\u30fc\u30df\u30f3\u30b0\u30a2\u30c3\u30d7\u3067\u3059\u306d\u3002<\/p>\n<p><code>... WHERE \u58f2\u4e0a\u65e5 <strong>BETWEEN<\/strong> '2025-04-01' AND '2025-04-30'<\/code><\/p>\n<h5>\u601d\u8003\u30d1\u30bf\u30fc\u30f3\u2461\uff1a\u6700\u91cd\u8981\uff01\u526f\u554f\u3044\u5408\u308f\u305b\u3092\u4f7f\u3044\u3053\u306a\u3059<\/h5>\n<p>\u5fdc\u7528\u60c5\u5831\u3067\u6700\u3082\u72d9\u308f\u308c\u308b\u306e\u304c\u3001<strong>\u526f\u554f\u3044\u5408\u308f\u305b\uff08Subquery\uff09<\/strong>\u3092\u4f7f\u3063\u305f\u6761\u4ef6\u5f0f\u3067\u3059\u3002<code>WHERE<\/code>\u53e5\u306e\u6761\u4ef6\u306b\u3001\u5225\u306e<code>SELECT<\/code>\u6587\u306e\u7d50\u679c\u3092\u5229\u7528\u3059\u308b\u30d1\u30bf\u30fc\u30f3\u3067\u3001\u7279\u306b<code>IN<\/code>\u3068<code>EXISTS<\/code>\u306f\u983b\u51fa\u4e2d\u306e\u983b\u51fa\u3067\u3059\u3002<\/p>\n<div style=\"background-color: #fef9e7; border-left: 5px solid #f1c40f; padding: 15px; margin-bottom: 15px;\"><strong>\u3010IN\uff1a\u5024\u306e\u96c6\u5408\u306b\u542b\u307e\u308c\u308b\u304b\uff1f\u3011<\/strong><br \/>\n<code>IN<\/code>\u306f\u3001\u3042\u308b\u5217\u306e\u5024\u304c\u300c( )\u5185\u306b\u6307\u5b9a\u3055\u308c\u305f\u5024\u306e\u30ea\u30b9\u30c8\u306e<strong>\u3044\u305a\u308c\u304b\u306b\u542b\u307e\u308c\u3066\u3044\u308b\u304b<\/strong>\u300d\u3092\u30c1\u30a7\u30c3\u30af\u3057\u307e\u3059\u3002<br \/>\n<strong>\u6587\u8108\uff1a<\/strong>\u300c\u6771\u4eac\u307e\u305f\u306f\u5927\u962a\u306b\u652f\u793e\u304c\u3042\u308b\u90e8\u7f72\u306e\u793e\u54e1\u300d\u300cA\u5546\u54c1\u307e\u305f\u306fB\u5546\u54c1\u3092\u8cfc\u5165\u3057\u305f\u9867\u5ba2\u300d\u306a\u3069\u3001\u8907\u6570\u306e\u5019\u88dc\u306e\u3046\u3061\u3001\u3069\u308c\u304b\u4e00\u3064\u306b\u3067\u3082\u5f53\u3066\u306f\u307e\u308b\u3082\u306e\u3092\u63a2\u3059\u3068\u304d\u306b\u4f7f\u3044\u307e\u3059\u3002<br \/>\n<strong>\u601d\u8003\u6cd5\uff1a<\/strong>\u7a7a\u6b04\u306e\u524d\u304c\u5217\u540d\u3067\u3001\u5f8c\u308d\u304c`( )`\u3067\u56f2\u307e\u308c\u305f<code>SELECT<\/code>\u6587\u306a\u3089\u3001\u307e\u305a<code>IN<\/code>\u3092\u7591\u3044\u307e\u3057\u3087\u3046\u3002\u300c\uff5e\u306e\u3044\u305a\u308c\u304b\u306b\u4e00\u81f4\u3059\u308b\u300d\u3068\u3044\u3046\u6587\u8108\u3092\u63a2\u3057\u307e\u3059\u3002<br \/>\n<strong>SQL\u4f8b\uff1a<\/strong><code>... WHERE \u90e8\u7f72\u30b3\u30fc\u30c9 <strong>IN<\/strong> (SELECT \u90e8\u7f72\u30b3\u30fc\u30c9 FROM \u90e8\u7f72\u30de\u30b9\u30bf WHERE \u6240\u5728\u5730 = '\u6771\u4eac')<\/code><br \/>\n(\u2192 \u90e8\u7f72\u30b3\u30fc\u30c9\u304c\u3001&#8217;\u6771\u4eac&#8217;\u306b\u3042\u308b\u90e8\u7f72\u30b3\u30fc\u30c9\u306e\u30ea\u30b9\u30c8\u306b\u542b\u307e\u308c\u3066\u3044\u308b\u304b\uff1f)<\/div>\n<div style=\"background-color: #eafaf1; border-left: 5px solid #2ecc71; padding: 15px; margin-bottom: 15px;\"><strong>\u3010EXISTS\uff1a\u95a2\u9023\u30c7\u30fc\u30bf\u304c\u5b58\u5728\u3059\u308b\u304b\uff1f\u3011<\/strong><br \/>\n<code>EXISTS<\/code>\u306f\u3001\u300c( )\u5185\u306e\u526f\u554f\u3044\u5408\u308f\u305b\u3092\u5b9f\u884c\u3057\u305f\u7d50\u679c\u3001<strong>\u4e00\u4ef6\u3067\u3082\u884c\u304c\u8fd4\u3063\u3066\u304f\u308b\u304b<\/strong>\u300d\u3092\u30c1\u30a7\u30c3\u30af\u3057\u307e\u3059\u3002\u5024\u305d\u306e\u3082\u306e\u3067\u306f\u306a\u304f\u3001\u95a2\u9023\u30c7\u30fc\u30bf\u306e\u300c\u5b58\u5728\u6709\u7121\u300d\u3092\u554f\u3046\u306e\u304c\u30dd\u30a4\u30f3\u30c8\u3067\u3059\u3002<br \/>\n<strong>\u6587\u8108\uff1a<\/strong>\u300c\u4e00\u5ea6\u3067\u3082\u5546\u54c1\u3092\u8cfc\u5165\u3057\u305f\u3053\u3068\u304c\u3042\u308b\u9867\u5ba2\u300d\u300c\u8b1b\u7fd2\u4f1a\u306b\u7533\u3057\u8fbc\u307f\u304c\u3042\u308b\u8b1b\u5ea7\u300d\u306a\u3069\u3001\u300c\uff5e\u3057\u305f\u3053\u3068\u304c\u3042\u308b\u300d\u300c\uff5e\u304c\u5b58\u5728\u3059\u308b\u300d\u3068\u3044\u3046\u4e8b\u5b9f\u3092\u78ba\u8a8d\u3057\u305f\u3044\u3068\u304d\u306b\u4f7f\u3044\u307e\u3059\u3002<br \/>\n<strong>\u601d\u8003\u6cd5\uff1a<\/strong><code>EXISTS<\/code>\u306e\u526f\u554f\u3044\u5408\u308f\u305b\u306f\u3001\u4e3b\u554f\u3044\u5408\u308f\u305b\u306e\u30c6\u30fc\u30d6\u30eb\u3068\u95a2\u9023\u4ed8\u3051\u308b\u76f8\u95a2\u526f\u554f\u5408\u305b\u306b\u306a\u308b\u3053\u3068\u304c\u307b\u3068\u3093\u3069\u3067\u3059\u3002<code>... WHERE EXISTS (SELECT * FROM \u6ce8\u6587\u30c6\u30fc\u30d6\u30eb WHERE \u6ce8\u6587\u30c6\u30fc\u30d6\u30eb.\u9867\u5ba2\u756a\u53f7 = \u9867\u5ba2\u30de\u30b9\u30bf.\u9867\u5ba2\u756a\u53f7)<\/code> \u306e\u3088\u3046\u306b\u3001\u526f\u554f\u3044\u5408\u308f\u305b\u306e\u4e2d\u306b\u4e3b\u554f\u3044\u5408\u308f\u305b\u306e\u5217\u304c\u767b\u5834\u3057\u305f\u3089\u3001<code>EXISTS<\/code>\u304c\u6fc3\u539a\u3067\u3059\u3002<br \/>\n<strong>SQL\u4f8b\uff1a<\/strong><code>... FROM \u9867\u5ba2\u30de\u30b9\u30bf a WHERE <strong>EXISTS<\/strong> (SELECT * FROM \u6ce8\u6587\u5c65\u6b74 b WHERE a.\u9867\u5ba2\u756a\u53f7 = b.\u9867\u5ba2\u756a\u53f7)<\/code><br \/>\n(\u2192 \u9867\u5ba2\u30de\u30b9\u30bf\u306e\u5404\u884c\u306b\u5bfe\u3057\u3066\u3001\u540c\u3058\u9867\u5ba2\u756a\u53f7\u3092\u6301\u3064\u6ce8\u6587\u5c65\u6b74\u304c\u5b58\u5728\u3059\u308b\u304b\uff1f)<\/div>\n<p><strong>\u3010\u4f7f\u3044\u5206\u3051\u306e\u30dd\u30a4\u30f3\u30c8\u3011<\/strong><br \/>\n\u3056\u3063\u304f\u308a\u8a00\u3046\u3068\u3001<strong><code>IN<\/code>\u306f\u300c\u5024\u300d\u306e\u30ea\u30b9\u30c8\u3068\u306e\u6bd4\u8f03<\/strong>\u3001<strong><code>EXISTS<\/code>\u306f\u95a2\u9023\u3059\u308b\u300c\u884c\u300d\u306e\u5b58\u5728\u30c1\u30a7\u30c3\u30af<\/strong>\u3067\u3059\u3002\u3069\u3061\u3089\u3082\u540c\u3058\u7d50\u679c\u3092\u5f97\u3089\u308c\u308b\u3053\u3068\u3082\u591a\u3044\u3067\u3059\u304c\u3001\u554f\u984c\u306eE-R\u56f3\u3084\u524d\u5f8c\u306eSQL\u6587\u304b\u3089\u3001\u3069\u3061\u3089\u306e\u66f8\u304d\u65b9\u304c\u81ea\u7136\u304b\uff08\u3042\u308b\u3044\u306f\u3001\u3069\u3061\u3089\u304b\u3067\u306a\u3044\u3068\u66f8\u3051\u306a\u3044\u304b\uff09\u3092\u5224\u65ad\u3059\u308b\u306e\u304c\u8155\u306e\u898b\u305b\u6240\u3067\u3059\u3002<\/p>\n<h4>4-3. \u3010\u5834\u6240\uff1aGROUP BY \/ HAVING\u53e5\u3011 \u96c6\u8a08\u3068\u7d5e\u308a\u8fbc\u307f\u306e\u6700\u5f37\u30b3\u30f3\u30d3<\/h4>\n<p><code>GROUP BY<\/code>\u3068<code>HAVING<\/code>\u306f\u3001\u5fc5\u305a\u30bb\u30c3\u30c8\u3067\u5b66\u7fd2\u3059\u3079\u304d\u5144\u5f1f\u306e\u3088\u3046\u306a\u53e5\u3067\u3059\u3002\u5f79\u5272\u306f\u300c\u30b0\u30eb\u30fc\u30d7\u5316\u300d\u3068\u300c\u30b0\u30eb\u30fc\u30d7\u306b\u5bfe\u3059\u308b\u7d5e\u308a\u8fbc\u307f\u300d\u3002\u3053\u3053\u3092\u5236\u3059\u308b\u8005\u306f\u3001\u96c6\u8a08\u554f\u984c\u3092\u5236\u3057\u307e\u3059\u3002<\/p>\n<h5>\u601d\u8003\u30d1\u30bf\u30fc\u30f3\u2460\uff1aGROUP BY\u3092\u547c\u3076\u300c\u96c6\u7d04\u95a2\u6570\u300d\u306e\u30b5\u30a4\u30f3<\/h5>\n<p>\u307e\u305a<code>GROUP BY<\/code>\u53e5\u3067\u3059\u3002\u3053\u308c\u306f\u3001\u7279\u5b9a\u306e\u5217\u306e\u5024\u304c\u540c\u3058\u884c\u3092\u4e00\u3064\u306e\u30b0\u30eb\u30fc\u30d7\u306b\u307e\u3068\u3081\u308b\u5f79\u5272\u3092\u6301\u3061\u307e\u3059\u3002\u3067\u306f\u3001\u3069\u3093\u306a\u6642\u306b\u5fc5\u8981\u306b\u306a\u308b\u306e\u3067\u3057\u3087\u3046\u304b\uff1f<\/p>\n<p><strong>\u9244\u5247\uff1a<\/strong><code>SELECT<\/code>\u53e5\u306b<strong>\u96c6\u7d04\u95a2\u6570\uff08<code>COUNT<\/code>, <code>SUM<\/code>, <code>AVG<\/code>, <code>MAX<\/code>, <code>MIN<\/code>\uff09\u3068\u3001\u305d\u308c\u4ee5\u5916\u306e\u901a\u5e38\u306e\u5217\u540d\u304c\u6df7\u5728\u3057\u3066\u3044\u308b\u5834\u5408\u3001<code>GROUP BY<\/code>\u53e5\u306f\u5fc5\u9808<\/strong>\u3067\u3059\u3002<\/p>\n<p><code>SELECT \u90e8\u7f72\u540d, <strong>COUNT(<\/strong>\u793e\u54e1\u756a\u53f7<strong>)<\/strong> FROM ...<\/code><\/p>\n<p>\u4e0a\u8a18\u306e\u3088\u3046\u306b\u3001\u300c\u90e8\u7f72\u540d\u300d\u3068\u3044\u3046\u901a\u5e38\u306e\u5217\u3068\u3001\u300c\u793e\u54e1\u756a\u53f7\u306e\u4ef6\u6570\u300d\u3068\u3044\u3046\u96c6\u7d04\u7d50\u679c\u3092\u540c\u6642\u306b\u8868\u793a\u3057\u305f\u3044\u5834\u5408\u3001\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u306f\u300c\u3069\u306e\u5358\u4f4d\u3067\u4eba\u6570\u3092\u6570\u3048\u308c\u3070\u3044\u3044\u306e\uff1f\u300d\u3068\u8ff7\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002\u305d\u3053\u3067\u3001<code>GROUP BY \u90e8\u7f72\u540d<\/code>\u3068\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067\u3001\u300c\u90e8\u7f72\u540d\u3054\u3068\u306b\u30b0\u30eb\u30fc\u30d7\u5316\u3057\u3066\u3001\u305d\u306e\u30b0\u30eb\u30fc\u30d7\u5185\u3067\u793e\u54e1\u6570\u3092\u6570\u3048\u3066\u306d\u300d\u3068\u6307\u793a\u3057\u3066\u3042\u3052\u308b\u308f\u3051\u3067\u3059\u3002<\/p>\n<p><strong>\u7a7a\u6b04\u306e\u6cd5\u5247\uff1a<\/strong><code>GROUP BY<\/code>\u53e5\u306e\u7a7a\u6b04\u306b\u5165\u308b\u306e\u306f\u3001<strong><code>SELECT<\/code>\u53e5\u306b\u3042\u308b\u300c\u96c6\u7d04\u95a2\u6570\u3067\u56f2\u307e\u308c\u3066\u3044\u306a\u3044\u5217\u300d<\/strong>\u3067\u3059\u3002\u3053\u308c\u306f\u975e\u5e38\u306b\u5f37\u529b\u306a\u6cd5\u5247\u306a\u306e\u3067\u3001\u7d76\u5bfe\u306b\u899a\u3048\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h5>\u601d\u8003\u30d1\u30bf\u30fc\u30f3\u2461\uff1aHAVING\u306f\u300c\u30b0\u30eb\u30fc\u30d7\u3078\u306e\u6761\u4ef6\u6307\u5b9a\u300d<\/h5>\n<p>\u6b21\u306b<code>HAVING<\/code>\u53e5\u3067\u3059\u3002\u3053\u308c\u306f\u3001<code>GROUP BY<\/code>\u3067\u4f5c\u3089\u308c\u305f\u30b0\u30eb\u30fc\u30d7\u306e\u4e2d\u304b\u3089\u3001\u3055\u3089\u306b\u6761\u4ef6\u306b\u5408\u3046\u3082\u306e\u3060\u3051\u3092\u7d5e\u308a\u8fbc\u3080\u5f79\u5272\u3092\u6301\u3061\u307e\u3059\u3002<\/p>\n<p>\u3053\u3053\u3067\u3001\u591a\u304f\u306e\u4eba\u304c\u300c\u3042\u308c\u3001\u6761\u4ef6\u6307\u5b9a\u306a\u3089<code>WHERE<\/code>\u53e5\u3058\u3083\u30c0\u30e1\u306a\u306e\uff1f\u300d\u3068\u7591\u554f\u306b\u601d\u3044\u307e\u3059\u3002\u4e21\u8005\u306e\u9055\u3044\u3092\u660e\u78ba\u306b\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<div style=\"border: 2px solid #e74c3c; padding: 15px; border-radius: 8px; background-color: #fdedec;\"><strong>\u3010WHERE \u3068 HAVING \u306e\u6c7a\u5b9a\u7684\u306a\u9055\u3044\u3011<\/strong><\/p>\n<ul>\n<li><strong>WHERE\u53e5\uff1a<\/strong>\u30b0\u30eb\u30fc\u30d7\u5316\u3059\u308b<strong>\u524d<\/strong>\u306b\u3001\u4e00\u884c\u4e00\u884c\u3092\u5be9\u67fb\u3059\u308b\u3002\u300c\u500b\u4eba\u6226\u300d\u306e\u30d5\u30a3\u30eb\u30bf\u30fc\u3002<br \/>\n&#x27a1;&#xfe0f; (\u4f8b) <code>WHERE \u5f79\u8077 = '\u90e8\u9577'<\/code> \uff08\u5f79\u8077\u304c\u90e8\u9577\u306e\u201c\u4eba\u201d\u3092\u307e\u305a\u96c6\u3081\u308b\uff09<\/li>\n<li><strong>HAVING\u53e5\uff1a<\/strong>\u30b0\u30eb\u30fc\u30d7\u5316\u3057\u305f<strong>\u5f8c<\/strong>\u306b\u3001\u30b0\u30eb\u30fc\u30d7\u3054\u3068\u5be9\u67fb\u3059\u308b\u3002\u300c\u56e3\u4f53\u6226\u300d\u306e\u30d5\u30a3\u30eb\u30bf\u30fc\u3002<br \/>\n&#x27a1;&#xfe0f; (\u4f8b) <code>HAVING COUNT(*) &gt;= 5<\/code> \uff08\u30e1\u30f3\u30d0\u30fc\u304c5\u4eba\u4ee5\u4e0a\u306e\u201c\u90e8\u7f72\u201d\u3060\u3051\u3092\u6b8b\u3059\uff09<\/li>\n<\/ul>\n<p><strong>\u91cd\u8981\uff1a<\/strong><code>HAVING<\/code>\u53e5\u306e\u6761\u4ef6\u5f0f\u306b\u306f\u3001<strong>\u5fc5\u305a\u96c6\u7d04\u95a2\u6570\u304c\u542b\u307e\u308c\u307e\u3059<\/strong>\u3002\u3053\u308c\u3082\u9244\u5247\u3067\u3059\u3002<\/p>\n<\/div>\n<p><strong>\u6587\u8108\u306e\u30d2\u30f3\u30c8\uff1a<\/strong>\u554f\u984c\u6587\u306b\u300c\uff5e\u3054\u3068\u306e\u5e73\u5747\u70b9\u304c70\u70b9\u4ee5\u4e0a\u306e&#8230;\u300d\u300c\u4eba\u6570\u304c3\u4eba\u4ee5\u4e0a\u306e\u90e8\u7f72\u300d\u300c\u5408\u8a08\u91d1\u984d\u304c10\u4e07\u5186\u3092\u8d85\u3048\u308b\u9867\u5ba2\u300d\u3068\u3044\u3063\u305f\u3001<strong>\u96c6\u8a08\u7d50\u679c\u306b\u5bfe\u3059\u308b\u6761\u4ef6<\/strong>\u304c\u66f8\u304b\u308c\u3066\u3044\u305f\u3089\u3001\u305d\u308c\u306f<code>HAVING<\/code>\u53e5\u306e\u51fa\u756a\u304c\u6765\u305f\u3068\u3044\u3046\u30b5\u30a4\u30f3\u3067\u3059\u3002<\/p>\n<p><strong>SQL\u4f8b\uff1a<\/strong><br \/>\n<code>SELECT \u90e8\u7f72\u540d, COUNT(*)<\/code><br \/>\n<code>FROM \u793e\u54e1\u30c6\u30fc\u30d6\u30eb<\/code><br \/>\n<code><strong>WHERE<\/strong> \u5165\u793e\u5e74\u5ea6 &gt;= 2020<\/code> &#8212; (\u500b\u4eba\u3092\u7d5e\u308a\u8fbc\u307f)<br \/>\n<code><strong>GROUP BY<\/strong> \u90e8\u7f72\u540d<\/code><br \/>\n<code><strong>HAVING COUNT(*) &gt;= 3<\/strong><\/code>; &#8212; (\u30b0\u30eb\u30fc\u30d7\u3092\u7d5e\u308a\u8fbc\u307f)<\/p>\n<p>\u3053\u306e\u300cWHERE\u3067\u500b\u4eba\u6226\u3001GROUP BY\u3067\u30c1\u30fc\u30e0\u5206\u3051\u3001HAVING\u3067\u56e3\u4f53\u6226\u300d\u3068\u3044\u3046\u6d41\u308c\u3092\u63b4\u3081\u3070\u3001\u3082\u3046\u8ff7\u3046\u3053\u3068\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<h4>4-4. \u3010\u5834\u6240\uff1aSELECT\u53e5\u3011 \u6700\u7d42\u30a2\u30a6\u30c8\u30d7\u30c3\u30c8\u306e\u5316\u7ca7\u5e2b<\/h4>\n<p><code>SELECT<\/code>\u53e5\u306f\u3001\u30af\u30a8\u30ea\u3067\u8868\u793a\u3059\u308b\u5217\u3092\u6700\u7d42\u7684\u306b\u5b9a\u7fa9\u3059\u308b\u5834\u6240\u3067\u3059\u3002\u51e6\u7406\u9806\u5e8f\u3067\u306f\u5f8c\u308d\u306e\u65b9\u3067\u3059\u304c\u3001\u79c1\u305f\u3061\u304c\u66f8\u304f\u3068\u304d\u306f\u4e00\u756a\u6700\u521d\u306b\u6765\u308b\u3001\u307e\u3055\u306b\u30af\u30a8\u30ea\u306e\u300c\u9854\u300d\u3067\u3059\u3002\u3053\u3053\u306e\u7a7a\u6b04\u3067\u306f\u3001\u4f55\u3092\u8868\u793a\u3057\u305f\u3044\u306e\u304b\u3092\u7684\u78ba\u306b\u8868\u73fe\u3059\u308b\u80fd\u529b\u304c\u554f\u308f\u308c\u307e\u3059\u3002<\/p>\n<h5>\u601d\u8003\u30d1\u30bf\u30fc\u30f3\u2460\uff1a\u57fa\u672c\u306e\u5217\u540d\u3068\u3001\u304a\u99b4\u67d3\u307f\u306e\u96c6\u7d04\u95a2\u6570<\/h5>\n<p>\u6700\u3082\u30b7\u30f3\u30d7\u30eb\u306a\u306e\u306f\u3001\u8868\u793a\u3057\u305f\u3044\u5217\u540d\u3092\u30ab\u30f3\u30de\u533a\u5207\u308a\u3067\u4e26\u3079\u308b\u30d1\u30bf\u30fc\u30f3\u3067\u3059\u3002<code>SELECT \u793e\u54e1\u756a\u53f7, \u6c0f\u540d, ...<\/code> \u3068\u3044\u3063\u305f\u5f62\u3067\u3059\u306d\u3002<\/p>\n<p>\u307e\u305f\u3001<code>GROUP BY<\/code>\u53e5\u304c\u3042\u308b\u5834\u5408\u306f\u3001<code>COUNT(\u5217\u540d) AS \u4ef6\u6570<\/code> \u3084 <code>SUM(\u91d1\u984d) AS \u5408\u8a08\u91d1\u984d<\/code> \u306e\u3088\u3046\u306b\u3001\u96c6\u7d04\u95a2\u6570\u3068\u305d\u306e\u7d50\u679c\u306b\u540d\u524d\u3092\u3064\u3051\u308b\uff08<code>AS<\/code>\uff09\u30d1\u30bf\u30fc\u30f3\u304c\u983b\u51fa\u3067\u3059\u3002\u3053\u308c\u306f 4-3 \u3067\u898b\u305f\u901a\u308a\u3067\u3059\u306d\u3002<\/p>\n<h5>\u601d\u8003\u30d1\u30bf\u30fc\u30f3\u2461\uff1aSQL\u306eIF\u6587\u3001\u300cCASE\u300d\u5f0f\u3092\u4f7f\u3044\u3053\u306a\u3059<\/h5>\n<p><code>SELECT<\/code>\u53e5\u306e\u7a7a\u6b04\u3067\u5dee\u304c\u3064\u304f\u306e\u304c\u3001<strong><code>CASE<\/code>\u5f0f<\/strong>\u3067\u3059\u3002\u3053\u308c\u306f\u3001SQL\u6587\u306e\u4e2d\u306b\u300cIF-THEN-ELSE\u300d\u306e\u3088\u3046\u306a\u6761\u4ef6\u5206\u5c90\u30ed\u30b8\u30c3\u30af\u3092\u57cb\u3081\u8fbc\u3080\u305f\u3081\u306e\u5f37\u529b\u306a\u6b66\u5668\u3067\u3059\u3002<\/p>\n<p><strong>\u6587\u8108\u306e\u30d2\u30f3\u30c8\uff1a<\/strong>\u554f\u984c\u306e\u8981\u6c42\u4ed5\u69d8\u306b\u300c\uff5e\u306e\u5834\u5408\u306fA\u3068\u8868\u793a\u300d\u300c\uff5e\u306e\u5834\u5408\u306fB\u3068\u8868\u793a\u300d\u300c\u305d\u308c\u4ee5\u5916\u306fC\u3068\u8868\u793a\u300d\u306e\u3088\u3046\u306b\u3001<strong>\u6761\u4ef6\u306b\u3088\u3063\u3066\u8868\u793a\u5185\u5bb9\u3092\u5909\u3048\u305f\u3044<\/strong>\u3001\u3068\u3044\u3046\u8a18\u8ff0\u304c\u3042\u308c\u3070\u3001<code>CASE<\/code>\u5f0f\u306e\u51fa\u756a\u3092\u5f37\u304f\u7591\u3063\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div style=\"background-color: #e8f8f5; border-left: 5px solid #1abc9c; padding: 15px; margin-bottom: 15px;\"><strong>\u3010CASE\u5f0f\u306e\u57fa\u672c\u5f62\u3011<\/strong><code>CASE<\/code>\u3067\u59cb\u307e\u308a<code>END<\/code>\u3067\u7d42\u308f\u308b\u3001\u4e00\u584a\u306e\u51e6\u7406\u3067\u3059\u3002<\/p>\n<pre><code>\n<strong>CASE<\/strong>\n    <strong>WHEN<\/strong> \u6761\u4ef6\u5f0f1 <strong>THEN<\/strong> '\u7d50\u679c1'\n    <strong>WHEN<\/strong> \u6761\u4ef6\u5f0f2 <strong>THEN<\/strong> '\u7d50\u679c2'\n    <strong>ELSE<\/strong> '\u305d\u306e\u4ed6\u306e\u5834\u5408\u306e\u7d50\u679c'\n<strong>END<\/strong>\n<\/code><\/pre>\n<\/div>\n<p><strong>SQL\u4f8b\uff1a<\/strong>\u6210\u7e3e\u30c6\u30fc\u30d6\u30eb\u304b\u3089\u3001\u70b9\u6570\u306b\u5fdc\u3058\u3066\u300c\u512a\u300d\u300c\u826f\u300d\u300c\u53ef\u300d\u3092\u5224\u5b9a\u3057\u3066\u8868\u793a\u3059\u308b<\/p>\n<pre><code>\nSELECT\n    \u5b66\u751f\u756a\u53f7,\n    \u70b9\u6570,\n    <strong>CASE\n        WHEN \u70b9\u6570 &gt;= 90 THEN '\u512a'\n        WHEN \u70b9\u6570 &gt;= 70 THEN '\u826f'\n        ELSE '\u53ef'\n    END<\/strong> AS \u8a55\u4fa1\nFROM\n    \u6210\u7e3e\u30c6\u30fc\u30d6\u30eb;\n<\/code><\/pre>\n<p>\u3053\u306e\u3088\u3046\u306b\u3001\u5143\u306e\u30c6\u30fc\u30d6\u30eb\u306b\u306f\u5b58\u5728\u3057\u306a\u3044\u300c\u8a55\u4fa1\u300d\u3068\u3044\u3046\u65b0\u3057\u3044\u5217\u3092\u3001\u6761\u4ef6\u306b\u5fdc\u3058\u3066\u52d5\u7684\u306b\u4f5c\u308a\u51fa\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<code>SELECT<\/code>\u53e5\u306e\u7a7a\u6b04\u304c\u5c11\u3057\u9577\u304f\u3001\u6587\u8108\u306b\u6761\u4ef6\u5206\u5c90\u306e\u30cb\u30e5\u30a2\u30f3\u30b9\u304c\u3042\u308c\u3070\u3001\u3053\u306e<code>CASE<\/code>\u5f0f\u304c\u30d4\u30bf\u30ea\u3068\u306f\u307e\u308b\u3053\u3068\u304c\u591a\u3044\u3067\u3059\u3002<\/p>\n<h5>\u601d\u8003\u30d1\u30bf\u30fc\u30f3\u2462\uff1a\uff08\u5fdc\u7528\uff09\u30b9\u30ab\u30e9\u30fc\u526f\u554f\u3044\u5408\u308f\u305b<\/h5>\n<p>\u3082\u3046\u4e00\u3064\u3001\u5fdc\u7528\u7684\u306a\u30c6\u30af\u30cb\u30c3\u30af\u3068\u3057\u3066\u3001<code>SELECT<\/code>\u53e5\u306e\u4e2d\u306b\u76f4\u63a5<code>SELECT<\/code>\u6587\u3092\u57cb\u3081\u8fbc\u3080\u300c\u30b9\u30ab\u30e9\u30fc\u526f\u554f\u3044\u5408\u308f\u305b\u300d\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u308c\u306f\u3001<strong>\u5fc5\u305a1\u884c1\u5217\u306e\u7d50\u679c\u3060\u3051\u3092\u8fd4\u3059<\/strong><code>SELECT<\/code>\u6587\u3067\u3001\u3042\u308b\u884c\u306e\u30c7\u30fc\u30bf\u306b\u95a2\u9023\u3059\u308b\u3001\u5225\u306e\u30c6\u30fc\u30d6\u30eb\u306e\u30d4\u30f3\u30dd\u30a4\u30f3\u30c8\u306a\u5024\u3092\u53d6\u5f97\u3057\u305f\u3044\u3068\u304d\u306b\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<p>\u4f8b\uff1a\u300c\u793e\u54e1\u4e00\u89a7\u3092\u8868\u793a\u3059\u308b\u969b\u306b\u3001\u5404\u793e\u54e1\u304c\u6240\u5c5e\u3059\u308b\u90e8\u7f72\u306e&#8221;\u5e73\u5747\u5e74\u9f62&#8221;\u3082\u4e00\u7dd2\u306b\u8868\u793a\u3059\u308b\u300d\u306a\u3069\u3002<\/p>\n<p>\u3053\u308c\u306f\u5c11\u3057\u8907\u96d1\u306a\u306e\u3067\u3001\u300c<code>SELECT<\/code>\u53e5\u306b\u3082\u526f\u554f\u3044\u5408\u308f\u305b\u304c\u5165\u308b\u3053\u3068\u304c\u3042\u308b\u3093\u3060\u306a\u300d\u304f\u3089\u3044\u306b\u982d\u306e\u7247\u9685\u306b\u7f6e\u3044\u3066\u304a\u3051\u3070\u3001\u5fdc\u7528\u60c5\u5831\u30ec\u30d9\u30eb\u3067\u306f\u5341\u5206\u3067\u3057\u3087\u3046\u3002<\/p>\n<h4>4-5. \u3010\u305d\u306e\u4ed6\u3011JOIN\u306e\u76f8\u68d2\u300cON\u300d\u3068\u3001\u66f4\u65b0\u7cfbSQL\u306e\u4f5c\u6cd5<\/h4>\n<p>\u6700\u5f8c\u306b\u3001\u3053\u308c\u307e\u3067\u89e3\u8aac\u3057\u305f\u53e5\u4ee5\u5916\u3067\u72d9\u308f\u308c\u3084\u3059\u3044\u3001\u3044\u304f\u3064\u304b\u306e\u91cd\u8981\u30d1\u30bf\u30fc\u30f3\u3092\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<h5>\u601d\u8003\u30d1\u30bf\u30fc\u30f3\u2460\uff1aJOIN\u306e\u76f8\u68d2\u3001<code>ON<\/code>\u53e5\uff08\u518d\u78ba\u8a8d\uff09<\/h5>\n<p>4-1\u3067\u3082\u89e6\u308c\u307e\u3057\u305f\u304c\u3001<code>JOIN<\/code>\u53e5\u306b\u306f<strong><code>ON<\/code><\/strong>\u53e5\u304c\u30da\u30a2\u3067\u767b\u5834\u3057\u3001\u30c6\u30fc\u30d6\u30eb\u9593\u306e\u7d50\u5408\u6761\u4ef6\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002\u3053\u3053\u306e\u7a7a\u6b04\u306f\u30b5\u30fc\u30d3\u30b9\u554f\u984c\u306b\u8fd1\u3044\u3067\u3059\u3002<\/p>\n<p><code>... FROM \u30c6\u30fc\u30d6\u30ebA a JOIN \u30c6\u30fc\u30d6\u30ebB b <strong>ON<\/strong> a.<strong>[ \u30a2 ]<\/strong> = b.<strong>[ \u30a4 ]<\/strong><\/code><\/p>\n<p><strong>\u7a7a\u6b04\u306e\u6cd5\u5247\uff1a<\/strong>\u7a7a\u6b04 [\u30a2] \u3068 [\u30a4] \u306b\u5165\u308b\u306e\u306f\u30012\u3064\u306e\u30c6\u30fc\u30d6\u30eb\u3092\u7e4b\u3050<strong>\u300c\u5916\u90e8\u30ad\u30fc\u300d\u3068\u300c\u4e3b\u30ad\u30fc\u300d\u306e\u30da\u30a2<\/strong>\u3067\u3059\u3002E-R\u56f3\u3092\u898b\u3066\u3001\u30c6\u30fc\u30d6\u30eb\u9593\u3092\u7d50\u3076\u7dda\u304c\u3069\u306e\u5217\uff08\u5c5e\u6027\uff09\u306b\u7e4b\u304c\u3063\u3066\u3044\u308b\u304b\u3092\u78ba\u8a8d\u3059\u308c\u3070\u3001\u4e00\u77ac\u3067\u898b\u629c\u3051\u307e\u3059\u3002<\/p>\n<h5>\u601d\u8003\u30d1\u30bf\u30fc\u30f3\u2461\uff1a\u30c7\u30fc\u30bf\u3092\u5909\u66f4\u3059\u308b\u300c\u66f4\u65b0\u7cfbSQL\u300d<\/h5>\n<p>\u5fdc\u7528\u60c5\u5831\u3067\u306f\u7a00\u3067\u3059\u304c\u3001\u30c7\u30fc\u30bf\u306e\u53c2\u7167(<code>SELECT<\/code>)\u3060\u3051\u3067\u306a\u304f\u3001\u8ffd\u52a0\u30fb\u66f4\u65b0\u30fb\u524a\u9664\u3092\u884c\u3046SQL\uff08DML: Data Manipulation Language\uff09\u304c\u554f\u308f\u308c\u308b\u3053\u3068\u3082\u3042\u308a\u307e\u3059\u3002\u69cb\u6587\u304c\u30b7\u30f3\u30d7\u30eb\u306a\u306e\u3067\u3001\u30ad\u30fc\u30ef\u30fc\u30c9\u3055\u3048\u899a\u3048\u3066\u3044\u308c\u3070\u5f97\u70b9\u6e90\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<div style=\"padding: 15px; margin-bottom: 15px;\"><strong>\u3010INSERT\uff1a\u30c7\u30fc\u30bf\u306e\u8ffd\u52a0\u3011<\/strong><br \/>\n\u65b0\u3057\u3044\u884c\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002\u300c\uff5e\u3092\u767b\u9332\u3059\u308b\u300d\u3068\u3044\u3046\u6587\u8108\u3067\u767b\u5834\u3057\u307e\u3059\u3002<\/p>\n<p><strong>SQL\u4f8b\uff1a<\/strong><code><strong>INSERT INTO<\/strong> \u793e\u54e1\u30c6\u30fc\u30d6\u30eb (\u793e\u54e1\u756a\u53f7, \u6c0f\u540d) <strong>VALUES<\/strong> ('E123', '\u60c5\u5831 \u592a\u90ce');<\/code><\/p>\n<p><strong>\u72d9\u308f\u308c\u308b\u7a7a\u6b04\uff1a<\/strong><code>INTO<\/code>\u3084<code>VALUES<\/code>\u3068\u3044\u3063\u305f\u3001\u69cb\u6587\u3092\u69cb\u6210\u3059\u308b\u30ad\u30fc\u30ef\u30fc\u30c9\u305d\u306e\u3082\u306e\u304c\u72d9\u308f\u308c\u3084\u3059\u3044\u3067\u3059\u3002<\/p>\n<\/div>\n<div style=\"padding: 15px; margin-bottom: 15px;\"><strong>\u3010UPDATE\uff1a\u30c7\u30fc\u30bf\u306e\u66f4\u65b0\u3011<\/strong><br \/>\n\u65e2\u5b58\u306e\u884c\u306e\u5024\u3092\u5909\u66f4\u3057\u307e\u3059\u3002\u300c\uff5e\u3092\u66f4\u65b0\u3059\u308b\u300d\u300c\uff5e\u306b\u5909\u66f4\u3059\u308b\u300d\u3068\u3044\u3046\u6587\u8108\u3067\u767b\u5834\u3057\u307e\u3059\u3002<\/p>\n<p><strong>SQL\u4f8b\uff1a<\/strong><code><strong>UPDATE<\/strong> \u793e\u54e1\u30c6\u30fc\u30d6\u30eb <strong>SET<\/strong> \u90e8\u7f72\u30b3\u30fc\u30c9 = 'D002' <strong>WHERE<\/strong> \u793e\u54e1\u756a\u53f7 = 'E123';<\/code><\/p>\n<p><strong>\u72d9\u308f\u308c\u308b\u7a7a\u6b04\uff1a<\/strong>\u66f4\u65b0\u3059\u308b\u5217\u3092\u6307\u5b9a\u3059\u308b<strong><code>SET<\/code><\/strong>\u306f\u6700\u983b\u51fa\u306e\u7a7a\u6b04\u5019\u88dc\u3067\u3059\u3002\u307e\u305f\u3001\u3069\u306e\u884c\u3092\u66f4\u65b0\u3059\u308b\u306e\u304b\u3092\u6307\u5b9a\u3059\u308b<code>WHERE<\/code>\u53e5\u306e\u6761\u4ef6\u3082\u3082\u3061\u308d\u3093\u554f\u308f\u308c\u307e\u3059\u3002<\/p>\n<\/div>\n<div style=\"padding: 15px; margin-bottom: 15px;\"><strong>\u3010DELETE\uff1a\u30c7\u30fc\u30bf\u306e\u524a\u9664\u3011<\/strong><br \/>\n\u65e2\u5b58\u306e\u884c\u3092\u524a\u9664\u3057\u307e\u3059\u3002\u300c\uff5e\u3092\u524a\u9664\u3059\u308b\u300d\u3068\u3044\u3046\u6587\u8108\u3067\u767b\u5834\u3057\u307e\u3059\u3002<\/p>\n<p><strong>SQL\u4f8b\uff1a<\/strong><code><strong>DELETE FROM<\/strong> \u793e\u54e1\u30c6\u30fc\u30d6\u30eb <strong>WHERE<\/strong> \u5728\u7c4d\u72b6\u6cc1 = '\u9000\u8077';<\/code><\/p>\n<p><strong>\u72d9\u308f\u308c\u308b\u7a7a\u6b04\uff1a<\/strong>\u3069\u306e\u30c6\u30fc\u30d6\u30eb\u304b\u3089\u524a\u9664\u3059\u308b\u304b\u3092\u6307\u5b9a\u3059\u308b<strong><code>FROM<\/code><\/strong>\u304c\u7a7a\u6b04\u306b\u306a\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<code>UPDATE<\/code>\u3068\u540c\u69d8\u3001\u3069\u306e\u884c\u3092\u6d88\u3059\u304b\u3092\u6c7a\u3081\u308b<code>WHERE<\/code>\u53e5\u304c\u975e\u5e38\u306b\u91cd\u8981\u3067\u3059\u3002<\/p>\n<\/div>\n<p>\u3053\u308c\u3067\u3001SQL\u7a7a\u6b04\u88dc\u5145\u554f\u984c\u3067\u906d\u9047\u3059\u308b\u3067\u3042\u308d\u3046\u3001\u307b\u3068\u3093\u3069\u306e\u30d1\u30bf\u30fc\u30f3\u3092\u5730\u56f3\u306b\u53ce\u3081\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u3002\u6b21\u306e\u7ae0\u3067\u306f\u3001\u3053\u306e\u5730\u56f3\u3092\u7247\u624b\u306b\u3001\u5b9f\u969b\u306e\u904e\u53bb\u554f\u3068\u3044\u3046\u540d\u306e\u5192\u967a\u306b\u51fa\u767a\u3057\u307e\u3057\u3087\u3046\uff01<\/p>\n<h3>5. \u53b3\u9078\u904e\u53bb\u554f\u3068\u601d\u8003\u30c8\u30ec\u30fc\u30b9\uff1a\u540d\u63a2\u5075\u306e\u3088\u3046\u306b\u3001\u8ad6\u7406\u3067\u89e3\u304d\u660e\u304b\u3059<\/h3>\n<p>\u7406\u8ad6\u306f\u3082\u3046\u5341\u5206\u3067\u3059\u3002\u3053\u3053\u304b\u3089\u306f\u3001\u5b9f\u969b\u306e\u904e\u53bb\u554f\uff08\u203b\uff09\u3092\u4f7f\u3063\u3066\u3001\u3053\u308c\u307e\u3067\u5b66\u3093\u3060\u601d\u8003\u30d7\u30ed\u30bb\u30b9\u3092\u5b9f\u8df5\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u982d\u306e\u4e2d\u3067\u3001\u3053\u3093\u306a\u98a8\u306b\u8003\u3048\u3066\u3044\u3051\u3070\u6b63\u89e3\u306b\u305f\u3069\u308a\u7740\u3051\u308b\u3001\u3068\u3044\u3046\u6d41\u308c\u3092\u4f53\u611f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><small>\u203b \u3053\u3053\u3067\u306f\u3001\u5fdc\u7528\u60c5\u5831\u6280\u8853\u8005\u8a66\u9a13\u3067\u983b\u51fa\u306e\u30ed\u30b8\u30c3\u30af\u3092\u57fa\u306b\u3057\u305f\u5178\u578b\u7684\u306a\u554f\u984c\u4f8b\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/small><\/p>\n<h4>\u554f\u984c\u8a2d\u5b9a<\/h4>\n<p>\u3042\u308bEC\u30b5\u30a4\u30c8\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u306f\u3001\u5546\u54c1\u3092\u7ba1\u7406\u3059\u308b\u300c\u5546\u54c1\u30de\u30b9\u30bf\u300d\u3068\u3001\u6ce8\u6587\u660e\u7d30\u3092\u7ba1\u7406\u3059\u308b\u300c\u6ce8\u6587\u660e\u7d30\u30c6\u30fc\u30d6\u30eb\u300d\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<ul>\n<li><strong>\u5546\u54c1\u30de\u30b9\u30bf<\/strong> (<u>\u5546\u54c1\u30b3\u30fc\u30c9<\/u>, \u5546\u54c1\u540d, \u5358\u4fa1)<\/li>\n<li><strong>\u6ce8\u6587\u660e\u7d30\u30c6\u30fc\u30d6\u30eb<\/strong> (<u>\u6ce8\u6587\u756a\u53f7<\/u>, <u>\u884c\u756a\u53f7<\/u>, \u5546\u54c1\u30b3\u30fc\u30c9, \u6570\u91cf)<\/li>\n<\/ul>\n<p><strong>\u3010\u8981\u4ef6\u3011<\/strong>\u4e00\u5ea6\u3067\u3082\u6ce8\u6587\u3055\u308c\u305f\u3053\u3068\u304c\u3042\u308b\u5546\u54c1\u306e\u300c\u5546\u54c1\u30b3\u30fc\u30c9\u300d\u3068\u300c\u5546\u54c1\u540d\u300d\u3092\u4e00\u89a7\u8868\u793a\u3059\u308bSQL\u6587\u3092\u5b8c\u6210\u3055\u305b\u306a\u3055\u3044\u3002<\/p>\n<p><strong>\u3010SQL\u6587\u3011<\/strong><\/p>\n<pre><code>\nSELECT\n    T1.\u5546\u54c1\u30b3\u30fc\u30c9,\n    T1.\u5546\u54c1\u540d\nFROM\n    \u5546\u54c1\u30de\u30b9\u30bf AS T1\nWHERE\n    <strong>[ a ]<\/strong> (SELECT * FROM \u6ce8\u6587\u660e\u7d30\u30c6\u30fc\u30d6\u30eb AS T2 WHERE T1.\u5546\u54c1\u30b3\u30fc\u30c9 = T2.<strong>[ b ]<\/strong>)\n<\/code><\/pre>\n<hr \/>\n<h4>\u601d\u8003\u30c8\u30ec\u30fc\u30b9\u30fb\u30b9\u30bf\u30fc\u30c8\uff01<\/h4>\n<p><strong>\u3010\u30b9\u30c6\u30c3\u30d71\u3011\u554f\u984c\u306e\u8981\u4ef6\u3092\u5206\u89e3\u3059\u308b<\/strong><\/p>\n<p>\u307e\u305a\u3001\u554f\u984c\u6587\u306e\u30ad\u30e2\u306f\u3069\u3053\u3067\u3057\u3087\u3046\uff1f<br \/>\n\u300c<strong>\u4e00\u5ea6\u3067\u3082\u6ce8\u6587\u3055\u308c\u305f\u3053\u3068\u304c\u3042\u308b<\/strong>\u5546\u54c1\u300d\u3068\u3044\u3046\u90e8\u5206\u3067\u3059\u306d\u3002\u3053\u308c\u306f\u3064\u307e\u308a\u3001\u5546\u54c1\u30de\u30b9\u30bf\u306b\u3042\u308b\u5546\u54c1\u30b3\u30fc\u30c9\u304c\u3001\u6ce8\u6587\u660e\u7d30\u30c6\u30fc\u30d6\u30eb\u306b<strong>\u201c\u5b58\u5728\u3059\u308b\u201d<\/strong>\u304b\u3069\u3046\u304b\u3092\u30c1\u30a7\u30c3\u30af\u305b\u3088\u3001\u3068\u8a00\u3044\u63db\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><strong>\u3010\u30b9\u30c6\u30c3\u30d72\u3011\u7a7a\u6b04 [a] \u306e\u5019\u88dc\u3092\u7d5e\u308a\u8fbc\u3080<\/strong><\/p>\n<ol>\n<li><strong>\u5834\u6240\u306e\u78ba\u8a8d<\/strong>\uff1a\u7a7a\u6b04 <strong>[a]<\/strong> \u306f<code>WHERE<\/code>\u53e5\u306b\u3042\u308a\u3001\u305d\u306e\u5f8c\u308d\u306b\u306f<code>( )<\/code>\u3067\u56f2\u307e\u308c\u305f<code>SELECT<\/code>\u6587\uff08\u526f\u554f\u3044\u5408\u308f\u305b\uff09\u304c\u7d9a\u3044\u3066\u3044\u307e\u3059\u3002<\/li>\n<li><strong>\u30d1\u30bf\u30fc\u30f3\u306e\u9069\u7528<\/strong>\uff1a\u30bb\u30af\u30b7\u30e7\u30f34-2\u3067\u5b66\u3093\u3060\u300cWHERE\u53e5\u306e\u526f\u554f\u3044\u5408\u308f\u305b\u30d1\u30bf\u30fc\u30f3\u300d\u3092\u601d\u3044\u51fa\u3057\u307e\u3059\u3002\u3053\u306e\u5f62\u306e\u6700\u6709\u529b\u5019\u88dc\u306f<strong><code>IN<\/code><\/strong>\u3068<strong><code>EXISTS<\/code><\/strong>\u3067\u3057\u305f\u306d\u3002<\/li>\n<li><strong>\u6587\u8108\u306e\u5224\u65ad<\/strong>\uff1a\n<ul>\n<li>\u3082\u3057<code>IN<\/code>\u3092\u4f7f\u3046\u306a\u3089\u3001<code>WHERE T1.\u5546\u54c1\u30b3\u30fc\u30c9 IN (SELECT \u5546\u54c1\u30b3\u30fc\u30c9 FROM ...)<\/code> \u306e\u3088\u3046\u306b\u3001\u5024\u306e\u30ea\u30b9\u30c8\u3068\u6bd4\u8f03\u3059\u308b\u306f\u305a\u3067\u3059\u3002\u3057\u304b\u3057\u3001\u4eca\u56de\u306e\u526f\u554f\u3044\u5408\u308f\u305b\u306f<code>SELECT *<\/code>\u3068\u306a\u3063\u3066\u304a\u308a\u3001\u5024\u306e\u30ea\u30b9\u30c8\u3092\u8fd4\u3057\u3066\u3044\u307e\u305b\u3093\u3002<\/li>\n<li>\u4e00\u65b9\u3001<code>EXISTS<\/code>\u306f\u300c\u526f\u554f\u3044\u5408\u308f\u305b\u306e\u7d50\u679c\u304c1\u884c\u3067\u3082\u8fd4\u3063\u3066\u304f\u308b\u304b\uff08\uff1d\u5b58\u5728\u3059\u308b\u304b\uff09\u300d\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u6f14\u7b97\u5b50\u3067\u3057\u305f\u3002\u4eca\u56de\u306e\u8981\u4ef6\u300c\u4e00\u5ea6\u3067\u3082\u6ce8\u6587\u3055\u308c\u305f\u3053\u3068\u304c\u3042\u308b\uff08\uff1d\u6ce8\u6587\u660e\u7d30\u304c\u5b58\u5728\u3059\u308b\uff09\u300d\u306b\u30d4\u30c3\u30bf\u30ea\u5408\u81f4\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u7d50\u8ad6<\/strong>\uff1a\u3053\u306e\u6587\u8108\u3067\u306f<strong><code>EXISTS<\/code><\/strong>\u304c\u6700\u9069\u3060\u3068\u5224\u65ad\u3067\u304d\u307e\u3059\u3002<\/li>\n<\/ol>\n<p><strong>\u3010\u30b9\u30c6\u30c3\u30d73\u3011\u7a7a\u6b04 [b] \u306e\u5019\u88dc\u3092\u7d5e\u308a\u8fbc\u3080<\/strong><\/p>\n<ol>\n<li><strong>\u5834\u6240\u306e\u78ba\u8a8d<\/strong>\uff1a\u7a7a\u6b04 <strong>[b]<\/strong> \u306f\u3001\u526f\u554f\u3044\u5408\u308f\u305b\u5185\u306e<code>WHERE<\/code>\u53e5\u306b\u3042\u308a\u307e\u3059\u3002<code>WHERE T1.\u5546\u54c1\u30b3\u30fc\u30c9 = T2.[ b ]<\/code>\u3068\u3044\u3046\u5f62\u3067\u3059\u3002<\/li>\n<li><strong>\u30d1\u30bf\u30fc\u30f3\u306e\u9069\u7528<\/strong>\uff1a\u3053\u308c\u306f\u3001\u4e3b\u554f\u3044\u5408\u308f\u305b\u306e\u30c6\u30fc\u30d6\u30eb(<code>T1<\/code>=\u5546\u54c1\u30de\u30b9\u30bf)\u3068\u3001\u526f\u554f\u3044\u5408\u308f\u305b\u306e\u30c6\u30fc\u30d6\u30eb(<code>T2<\/code>=\u6ce8\u6587\u660e\u7d30\u30c6\u30fc\u30d6\u30eb)\u3092\u95a2\u9023\u4ed8\u3051\u308b\u300c<strong>\u76f8\u95a2\u526f\u554f\u5408\u305b<\/strong>\u300d\u306e\u5f62\u3067\u3059\u3002\u3053\u308c\u306f\u30bb\u30af\u30b7\u30e7\u30f34-1\u306e\u300cON\u53e5\u300d\u306e\u8003\u3048\u65b9\u3068\u5168\u304f\u540c\u3058\u3067\u3059\u30022\u3064\u306e\u30c6\u30fc\u30d6\u30eb\u3092\u7e4b\u3050\u30ad\u30fc\u3092\u63a2\u3057\u307e\u3059\u3002<\/li>\n<li><strong>E-R\u56f3\uff08\u30c6\u30fc\u30d6\u30eb\u5b9a\u7fa9\uff09\u306e\u78ba\u8a8d<\/strong>\uff1a\u5546\u54c1\u30de\u30b9\u30bf\u3068\u6ce8\u6587\u660e\u7d30\u30c6\u30fc\u30d6\u30eb\u3092\u7e4b\u3050\u5171\u901a\u306e\u5217\u306f\u3001\u660e\u3089\u304b\u306b\u300c\u5546\u54c1\u30b3\u30fc\u30c9\u300d\u3067\u3059\u3002<\/li>\n<li><strong>\u7d50\u8ad6<\/strong>\uff1a\u3057\u305f\u304c\u3063\u3066\u3001\u7a7a\u6b04 <strong>[b]<\/strong> \u306b\u5165\u308b\u306e\u306f<strong><code>\u5546\u54c1\u30b3\u30fc\u30c9<\/code><\/strong>\u3067\u9593\u9055\u3044\u3042\u308a\u307e\u305b\u3093\u3002<\/li>\n<\/ol>\n<p><strong>\u3010\u6700\u7d42\u89e3\u7b54\u3011<\/strong><\/p>\n<p>\u4ee5\u4e0a\u306e\u601d\u8003\u30d7\u30ed\u30bb\u30b9\u306b\u3088\u308a\u3001\u7b54\u3048\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5c0e\u304d\u51fa\u305b\u307e\u3059\u3002<\/p>\n<ul>\n<li><strong>a: <code>EXISTS<\/code><\/strong><\/li>\n<li><strong>b: <code>\u5546\u54c1\u30b3\u30fc\u30c9<\/code><\/strong><\/li>\n<\/ul>\n<p>\u3044\u304b\u304c\u3067\u3057\u305f\u304b\uff1f\u95c7\u96f2\u306b\u8003\u3048\u308b\u306e\u3067\u306f\u306a\u304f\u3001\u7a7a\u6b04\u306e\u300c\u5834\u6240\u300d\u3068\u300c\u6587\u8108\u300d\u304b\u3089\u30d1\u30bf\u30fc\u30f3\u3092\u9069\u7528\u3057\u3001\u8ad6\u7406\u7684\u306b\u7b54\u3048\u3092\u7d5e\u308a\u8fbc\u3093\u3067\u3044\u304f\u3002\u3053\u306e\u611f\u899a\u3092\u305c\u3072\u3001\u3054\u81ea\u8eab\u306e\u5b66\u7fd2\u306b\u3082\u53d6\u308a\u5165\u308c\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h3>6. \u672a\u6765\u3092\u4e88\u6e2c\u3059\u308b\u51fa\u984c\u4e88\u60f3\uff1a\u6b21\u306e\u6b66\u5668\u300c\u30a6\u30a3\u30f3\u30c9\u30a6\u95a2\u6570\u300d\u3068\u300cCTE\u300d\u3092\u77e5\u308b<\/h3>\n<p>\u3053\u3053\u307e\u3067\u306e\u77e5\u8b58\u3067\u3001\u5fdc\u7528\u60c5\u5831\u6280\u8853\u8005\u8a66\u9a13\u306eSQL\u554f\u984c\u306e9\u5272\u4ee5\u4e0a\u306f\u5bfe\u5fdc\u53ef\u80fd\u3067\u3059\u3002\u3057\u304b\u3057\u3001IT\u6280\u8853\u306f\u5e38\u306b\u9032\u5316\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u3053\u3067\u306f\u3001\u3042\u306a\u305f\u306e\u77e5\u7684\u597d\u5947\u5fc3\u3092\u523a\u6fc0\u3057\u3001\u30e9\u30a4\u30d0\u30eb\u306b\u4e00\u6b69\u5dee\u3092\u3064\u3051\u308b\u305f\u3081\u306e\u300c\u672a\u6765\u306e\u6b66\u5668\u300d\u30922\u3064\u3001\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3089\u306f\u9ad8\u5ea6\u8a66\u9a13\u3084\u5b9f\u52d9\u3067\u306f\u65e2\u306b\u5e38\u8b58\u3068\u306a\u308a\u3064\u3064\u3042\u308a\u3001\u3044\u3064\u5fdc\u7528\u60c5\u5831\u30ec\u30d9\u30eb\u306b\u964d\u308a\u3066\u304d\u3066\u3082\u304a\u304b\u3057\u304f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<h4>\u672a\u6765\u306e\u6b66\u5668\u2460\uff1a\u30a6\u30a3\u30f3\u30c9\u30a6\u95a2\u6570 (\u5206\u6790\u95a2\u6570)<\/h4>\n<p>\u300c\u30b0\u30eb\u30fc\u30d7\u3054\u3068\u306b\u96c6\u8a08\u3059\u308b\u300d\u306e\u304c<code>GROUP BY<\/code>\u3067\u3057\u305f\u3002\u305d\u308c\u306b\u5bfe\u3057\u3066\u300c<strong>\u30b0\u30eb\u30fc\u30d7\u5185\u306e\u9806\u4f4d\u4ed8\u3051<\/strong>\u300d\u3084\u300c<strong>\u30b0\u30eb\u30fc\u30d7\u5185\u3067\u306e\u524d\u5f8c\u306e\u884c\u3068\u306e\u6bd4\u8f03<\/strong>\u300d\u3092\u53ef\u80fd\u306b\u3059\u308b\u306e\u304c<strong>\u30a6\u30a3\u30f3\u30c9\u30a6\u95a2\u6570<\/strong>\u3067\u3059\u3002<\/p>\n<p><strong>\u6587\u8108\u306e\u30d2\u30f3\u30c8\uff1a<\/strong>\u300c\u90e8\u7f72<strong>\u3054\u3068\u306b<\/strong>\u7d66\u4e0e\u306e\u9ad8\u3044\u9806\u306b<strong>\u30e9\u30f3\u30ad\u30f3\u30b0<\/strong>\u3092\u4ed8\u3051\u305f\u3044\u300d\u300c\u5546\u54c1\u30ab\u30c6\u30b4\u30ea<strong>\u3054\u3068\u306b<\/strong>\u3001\u58f2\u4e0a\u306e\u7d2f\u8a08\u3092\u8a08\u7b97\u3057\u305f\u3044\u300d\u3068\u3044\u3063\u305f\u3001\u96c6\u8a08\u3068\u9806\u4f4d\u4ed8\u3051\u304c\u540c\u6642\u306b\u6c42\u3081\u3089\u308c\u305f\u3089\u3001\u30a6\u30a3\u30f3\u30c9\u30a6\u95a2\u6570\u306e\u51fa\u756a\u3067\u3059\u3002<\/p>\n<p><strong>SQL\u4f8b\uff1a<\/strong>\u90e8\u7f72\u3054\u3068\u306b\u7d66\u4e0e\u306e\u9ad8\u3044\u9806\u3067\u30e9\u30f3\u30ad\u30f3\u30b0\u3092\u4ed8\u3051\u308b<\/p>\n<pre><code>\nSELECT\n    \u6c0f\u540d,\n    \u90e8\u7f72\u540d,\n    \u7d66\u4e0e,\n    <strong>RANK() OVER (PARTITION BY \u90e8\u7f72\u540d ORDER BY \u7d66\u4e0e DESC)<\/strong> AS \u90e8\u7f72\u5185\u30e9\u30f3\u30af\nFROM\n    \u793e\u54e1\u30c6\u30fc\u30d6\u30eb;\n<\/code><\/pre>\n<ul>\n<li><code><strong>PARTITION BY \u90e8\u7f72\u540d<\/strong><\/code>\uff1a\u3053\u308c\u304c\u300c\u90e8\u7f72\u3054\u3068\u300d\u306b\u96c6\u8a08\u7bc4\u56f2\uff08\u30a6\u30a3\u30f3\u30c9\u30a6\uff09\u3092\u533a\u5207\u308b\u3001\u3068\u3044\u3046\u610f\u5473\u3067\u3059\u3002<code>GROUP BY<\/code>\u306e\u89aa\u621a\u306e\u3088\u3046\u306a\u3082\u306e\u3067\u3059\u306d\u3002<\/li>\n<li><code><strong>ORDER BY \u7d66\u4e0e DESC<\/strong><\/code>\uff1a\u305d\u306e\u30a6\u30a3\u30f3\u30c9\u30a6\u306e\u4e2d\u3067\u3001\u4f55\u9806\u306b\u4e26\u3079\u308b\u304b\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<li><code><strong>RANK()<\/strong><\/code>\uff1a\u305d\u3057\u3066\u3001\u305d\u306e\u9806\u4f4d\u3092\u8a08\u7b97\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n<p><code>GROUP BY<\/code>\u3068\u9055\u3063\u3066\u884c\u3092\u96c6\u7d04\u3057\u306a\u3044\u305f\u3081\u3001\u5143\u306e\u884c\u306e\u60c5\u5831\u3092\u6b8b\u3057\u305f\u307e\u307e\u3001\u30e9\u30f3\u30ad\u30f3\u30b0\u306a\u3069\u306e\u4ed8\u52a0\u60c5\u5831\u3092\u4ed8\u3051\u52a0\u3048\u3089\u308c\u308b\u306e\u304c\u5927\u304d\u306a\u30e1\u30ea\u30c3\u30c8\u3067\u3059\u3002<\/p>\n<h4>\u672a\u6765\u306e\u6b66\u5668\u2461\uff1a\u5171\u901a\u30c6\u30fc\u30d6\u30eb\u5f0f (CTE \/ WITH\u53e5)<\/h4>\n<p><code>FROM<\/code>\u53e5\u306e\u4e2d\u306b<code>SELECT<\/code>\u6587\u3092\u57cb\u3081\u8fbc\u3080\u300c\u526f\u554f\u3044\u5408\u308f\u305b\u300d\u306f\u3001\u5165\u308c\u5b50\uff08\u30cd\u30b9\u30c8\uff09\u304c\u6df1\u304f\u306a\u308b\u3068\u975e\u5e38\u306b\u8aad\u307f\u306b\u304f\u304f\u306a\u308b\u3001\u3068\u3044\u3046\u5f31\u70b9\u304c\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u3053\u306e\u5f31\u70b9\u3092\u514b\u670d\u3057\u3001SQL\u3092\u5287\u7684\u306b\u8aad\u307f\u3084\u3059\u304f\u3059\u308b\u306e\u304c<strong>\u5171\u901a\u30c6\u30fc\u30d6\u30eb\u5f0f\uff08CTE\uff09<\/strong>\u3001\u901a\u79f0<strong><code>WITH<\/code>\u53e5<\/strong>\u3067\u3059\u3002<\/p>\n<p><strong>\u601d\u8003\u6cd5\uff1a<\/strong>\u8907\u96d1\u306aSQL\u6587\u3092\u3001\u3044\u304f\u3064\u304b\u306e\u300c\u90e8\u54c1\u300d\u306b\u5206\u5272\u3057\u3066\u7d44\u307f\u7acb\u3066\u308b\u30a4\u30e1\u30fc\u30b8\u3067\u3059\u3002\u6700\u521d\u306b<code>WITH<\/code>\u53e5\u3067\u90e8\u54c1\uff08\u4e00\u6642\u7684\u306a\u4eee\u60f3\u30c6\u30fc\u30d6\u30eb\uff09\u3092\u5b9a\u7fa9\u3057\u3001\u30e1\u30a4\u30f3\u306e<code>SELECT<\/code>\u6587\u3067\u306f\u305d\u306e\u90e8\u54c1\u540d\u3092\u30b7\u30f3\u30d7\u30eb\u306b\u4f7f\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><strong>SQL\u4f8b\uff1a<\/strong>\u90e8\u9580\u3054\u3068\u306e\u5408\u8a08\u58f2\u4e0a\u3092\u8a08\u7b97\u3057\u3001\u305d\u306e\u7d50\u679c\u3092\u4f7f\u3063\u3066\u90e8\u7f72\u30de\u30b9\u30bf\u3068\u7d50\u5408\u3059\u308b<\/p>\n<pre><code>\n<strong>WITH<\/strong> \u90e8\u9580\u5225\u5408\u8a08\u58f2\u4e0a (\u90e8\u9580\u30b3\u30fc\u30c9, \u5408\u8a08\u58f2\u4e0a) AS (\n    SELECT\n        \u90e8\u9580\u30b3\u30fc\u30c9,\n        SUM(\u58f2\u4e0a\u984d)\n    FROM\n        \u58f2\u4e0a\u30c6\u30fc\u30d6\u30eb\n    GROUP BY\n        \u90e8\u9580\u30b3\u30fc\u30c9\n)\nSELECT\n    D.\u90e8\u9580\u540d,\n    S.\u5408\u8a08\u58f2\u4e0a\nFROM\n    \u90e8\u9580\u30de\u30b9\u30bf AS D\nJOIN\n    \u90e8\u9580\u5225\u5408\u8a08\u58f2\u4e0a AS S ON D.\u90e8\u9580\u30b3\u30fc\u30c9 = S.\u90e8\u9580\u30b3\u30fc\u30c9;\n<\/code><\/pre>\n<p>\u3044\u304b\u304c\u3067\u3057\u3087\u3046\u304b\u3002<code>WITH<\/code>\u53e5\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001\u307e\u305a\u300c\u90e8\u9580\u5225\u5408\u8a08\u58f2\u4e0a\u300d\u3068\u3044\u3046\u90e8\u54c1\u3092\u4f5c\u308a\u3001\u305d\u306e\u3042\u3068\u3067\u3058\u3063\u304f\u308a\u30e1\u30a4\u30f3\u306e\u51e6\u7406\u3092\u8a18\u8ff0\u3067\u304d\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001SQL\u6587\u5168\u4f53\u306e\u53ef\u8aad\u6027\u304c\u98db\u8e8d\u7684\u306b\u5411\u4e0a\u3057\u307e\u3059\u3002<\/p>\n<p>\u4eca\u306f\u300c\u3053\u3093\u306a\u4fbf\u5229\u306a\u3082\u306e\u304c\u3042\u308b\u3093\u3060\u300d\u3068\u3044\u3046\u7a0b\u5ea6\u306e\u7406\u89e3\u3067OK\u3067\u3059\u3002\u3057\u304b\u3057\u3001\u3053\u306e2\u3064\u3092\u77e5\u3063\u3066\u3044\u308b\u3060\u3051\u3067\u3001\u3042\u306a\u305f\u306f\u4ed6\u306e\u53d7\u9a13\u8005\u3088\u308a\u78ba\u5b9f\u306b\u4e00\u6b69\u5148\u3092\u884c\u3063\u3066\u3044\u307e\u3059\u3088\u3002<\/p>\n<h3>7. \u77e5\u8b58\u3092\u4f53\u7cfb\u5316\u3059\u308b\u95a2\u9023\u30de\u30c3\u30d7\uff1aSQL\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u76f8\u95a2\u56f3<\/h3>\n<p>\u304a\u75b2\u308c\u69d8\u3067\u3059\u3002\u3053\u3053\u307e\u3067\u3067\u3001SQL\u7a7a\u6b04\u88dc\u5145\u3092\u89e3\u304f\u305f\u3081\u306e\u69d8\u3005\u306a\u30ad\u30fc\u30ef\u30fc\u30c9\uff08\u6b66\u5668\uff09\u3092\u624b\u306b\u5165\u308c\u3066\u304d\u307e\u3057\u305f\u306d\u3002\u6700\u5f8c\u306b\u3001\u305d\u308c\u3089\u306e\u6b66\u5668\u304c\u3069\u306e\u30ab\u30c6\u30b4\u30ea\u30fc\u306b\u5c5e\u3057\u3001\u3069\u306e\u3088\u3046\u306b\u95a2\u9023\u3057\u3066\u3044\u308b\u306e\u304b\u3092\u4e00\u679a\u306e\u30de\u30c3\u30d7\u306b\u6574\u7406\u3057\u3001\u77e5\u8b58\u3092\u4f53\u7cfb\u5316\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<div style=\"border: 2px solid #3498db; padding: 15px; border-radius: 8px; background-color: #eaf2f8;\">\n<h4>SQL\u30b3\u30de\u30f3\u30c9\u4f53\u7cfb\u30de\u30c3\u30d7<\/h4>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li><strong>DML (Data Manipulation Language) &#8211; \u30c7\u30fc\u30bf\u64cd\u4f5c\u8a00\u8a9e<\/strong>\n<ul>\n<li><strong><code>SELECT<\/code> (\u30c7\u30fc\u30bf\u53c2\u7167)<\/strong> &#8211; \u6700\u3082\u91cd\u8981\uff01\n<ul>\n<li><code>FROM<\/code> &#8211; \u3069\u306e\u30c6\u30fc\u30d6\u30eb\u304b\u3089\uff1f\n<ul>\n<li><code>JOIN<\/code> &#8211; \u30c6\u30fc\u30d6\u30eb\u3092\u7d50\u5408 (<code>INNER<\/code>, <code>LEFT<\/code>)\n<ul>\n<li><code>ON<\/code> &#8211; \u7d50\u5408\u306e\u30ad\u30fc\u3092\u6307\u5b9a<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li><code>WHERE<\/code> &#8211; \u3069\u306e\u884c\u3092\uff1f (\u500b\u4eba\u6226\u30d5\u30a3\u30eb\u30bf\u30fc)\n<ul>\n<li><code>IN<\/code> &#8211; \u5024\u306e\u30ea\u30b9\u30c8\u306b\u542b\u307e\u308c\u308b\u304b\uff1f<\/li>\n<li><code>EXISTS<\/code> &#8211; \u95a2\u9023\u30c7\u30fc\u30bf\u304c\u5b58\u5728\u3059\u308b\u304b\uff1f<\/li>\n<\/ul>\n<\/li>\n<li><code>GROUP BY<\/code> &#8211; \u3069\u306e\u5358\u4f4d\u3067\u30b0\u30eb\u30fc\u30d7\u5316\uff1f<\/li>\n<li><code>HAVING<\/code> &#8211; \u3069\u306e\u30b0\u30eb\u30fc\u30d7\u3092\uff1f (\u56e3\u4f53\u6226\u30d5\u30a3\u30eb\u30bf\u30fc)<\/li>\n<li><code>SELECT<\/code> &#8211; \u3069\u306e\u5217\u3092\u8868\u793a\uff1f\n<ul>\n<li><code>CASE<\/code> &#8211; \u6761\u4ef6\u306b\u3088\u3063\u3066\u8868\u793a\u5185\u5bb9\u3092\u5909\u66f4<\/li>\n<li>\u96c6\u7d04\u95a2\u6570 (<code>COUNT<\/code>, <code>SUM<\/code>, <code>AVG<\/code>&#8230;)<\/li>\n<\/ul>\n<\/li>\n<li><code>ORDER BY<\/code> &#8211; \u3069\u306e\u9806\u3067\u4e26\u3079\u308b\uff1f<\/li>\n<\/ul>\n<\/li>\n<li><strong><code>INSERT<\/code> (\u30c7\u30fc\u30bf\u8ffd\u52a0)<\/strong>\n<ul>\n<li><code>INTO<\/code>, <code>VALUES<\/code><\/li>\n<\/ul>\n<\/li>\n<li><strong><code>UPDATE<\/code> (\u30c7\u30fc\u30bf\u66f4\u65b0)<\/strong>\n<ul>\n<li><code>SET<\/code>, <code>WHERE<\/code><\/li>\n<\/ul>\n<\/li>\n<li><strong><code>DELETE<\/code> (\u30c7\u30fc\u30bf\u524a\u9664)<\/strong>\n<ul>\n<li><code>FROM<\/code>, <code>WHERE<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li><strong>DDL (Data Definition Language) &#8211; \u30c7\u30fc\u30bf\u5b9a\u7fa9\u8a00\u8a9e<\/strong> (\u4eca\u56de\u306f\u6df1\u5165\u308a\u3057\u307e\u305b\u3093\u3067\u3057\u305f)\n<ul>\n<li><code>CREATE<\/code> &#8211; \u30c6\u30fc\u30d6\u30eb\u306a\u3069\u3092\u4f5c\u6210<\/li>\n<li><code>ALTER<\/code> &#8211; \u30c6\u30fc\u30d6\u30eb\u306a\u3069\u306e\u5b9a\u7fa9\u3092\u5909\u66f4<\/li>\n<li><code>DROP<\/code> &#8211; \u30c6\u30fc\u30d6\u30eb\u306a\u3069\u3092\u524a\u9664<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>DCL (Data Control Language) &#8211; \u30c7\u30fc\u30bf\u5236\u5fa1\u8a00\u8a9e<\/strong> (\u4eca\u56de\u306f\u6df1\u5165\u308a\u3057\u307e\u305b\u3093\u3067\u3057\u305f)\n<ul>\n<li><code>GRANT<\/code> &#8211; \u6a29\u9650\u3092\u4ed8\u4e0e<\/li>\n<li><code>REVOKE<\/code> &#8211; \u6a29\u9650\u3092\u5265\u596a<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/div>\n<p>&nbsp;<\/p>\n<p>\u3053\u306e\u30de\u30c3\u30d7\u3092\u6642\u3005\u773a\u3081\u308b\u3053\u3068\u3067\u3001\u300c\u3042\u3042\u3001<code>HAVING<\/code>\u306f<code>GROUP BY<\/code>\u3068\u30bb\u30c3\u30c8\u3060\u3063\u305f\u306a\u300d\u300c<code>IN<\/code>\u3084<code>EXISTS<\/code>\u306f<code>WHERE<\/code>\u53e5\u3067\u4f7f\u3046\u6b66\u5668\u3060\u3063\u305f\u306a\u300d\u3068\u3044\u3046\u98a8\u306b\u3001\u77e5\u8b58\u306e\u3064\u306a\u304c\u308a\u3092\u601d\u3044\u51fa\u3057\u3084\u3059\u304f\u306a\u308a\u307e\u3059\u3002\u305c\u3072\u3001\u3042\u306a\u305f\u306e\u982d\u306e\u4e2d\u306eSQL\u77e5\u8b58\u3092\u6574\u7406\u6574\u9813\u3059\u308b\u305f\u3081\u306b\u6d3b\u7528\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h3>8. \u3042\u306a\u305f\u3060\u3051\u306e\u5b66\u7fd2\u30ed\u30fc\u30c9\u30de\u30c3\u30d7\uff1a\u30ec\u30d9\u30eb\u5225\u30fb\u6700\u77ed\u653b\u7565\u30b3\u30fc\u30b9<\/h3>\n<p>\u3053\u306e\u8a18\u4e8b\u3067\u89e3\u8aac\u3057\u305f\u601d\u8003\u6cd5\u3092\u8eab\u306b\u3064\u3051\u308b\u305f\u3081\u306e\u3001\u5177\u4f53\u7684\u306a\u5b66\u7fd2\u30b9\u30c6\u30c3\u30d7\u3092\u30ec\u30d9\u30eb\u5225\u306b\u63d0\u6848\u3057\u307e\u3059\u3002\u3054\u81ea\u8eab\u306e\u73fe\u5728\u5730\u306b\u5408\u308f\u305b\u3066\u3001\u6700\u9069\u306a\u30b3\u30fc\u30b9\u3092\u9078\u3093\u3067\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h4>\u30b3\u30fc\u30b91\uff1aSQL\u82e6\u624b\u610f\u8b58\u514b\u670d\u30b3\u30fc\u30b9 (\u521d\u5b66\u8005\u5411\u3051)<\/h4>\n<p><strong>\u30b4\u30fc\u30eb\uff1a<\/strong>\u8907\u96d1\u306aSQL\u3078\u306e\u30a2\u30ec\u30eb\u30ae\u30fc\u3092\u306a\u304f\u3057\u3001\u300c\u3053\u308c\u306a\u3089\u89e3\u3051\u308b\u304b\u3082\u300d\u3068\u3044\u3046\u81ea\u4fe1\u3092\u6301\u3064\u3002<\/p>\n<hr>\n<p><strong>\u30b9\u30c6\u30c3\u30d7\u2460\uff1aSELECT, FROM, WHERE \u306e\u4e09\u7a2e\u306e\u795e\u5668\u3092\u56fa\u3081\u308b<\/strong><br \/>\n\u307e\u305a\u306f\u57fa\u672c\u4e2d\u306e\u57fa\u672c\u304b\u3089\u30021\u3064\u306e\u30c6\u30fc\u30d6\u30eb\u3092\u5bfe\u8c61\u306b\u3001<code>WHERE<\/code>\u53e5\u3067\u69d8\u3005\u306a\u6761\u4ef6\uff08<code>=, &gt;, BETWEEN, LIKE<\/code>\u306a\u3069\uff09\u3092\u6307\u5b9a\u3057\u3066\u30c7\u30fc\u30bf\u3092\u62bd\u51fa\u3059\u308b\u7df4\u7fd2\u3092\u7e70\u308a\u8fd4\u3057\u307e\u3057\u3087\u3046\u3002\u3053\u3053\u304c\u5168\u3066\u306e\u571f\u53f0\u3067\u3059\u3002<\/p>\n<p><strong>\u30b9\u30c6\u30c3\u30d7\u2461\uff1aINNER JOIN \u3067\u300c\u8868\u306e\u5408\u4f53\u300d\u306b\u6163\u308c\u308b<\/strong><br \/>\n\u6b21\u306b\u30012\u3064\u306e\u30c6\u30fc\u30d6\u30eb\u3092<code>INNER JOIN<\/code>\u3067\u7d50\u5408\u3059\u308b\u7df4\u7fd2\u3067\u3059\u3002\u300c\u793e\u54e1\u30c6\u30fc\u30d6\u30eb\u3068\u90e8\u7f72\u30c6\u30fc\u30d6\u30eb\u3092\u7d50\u5408\u3057\u3066\u3001\u793e\u54e1\u540d\u3068\u90e8\u7f72\u540d\u3092\u8868\u793a\u3059\u308b\u300d\u3068\u3044\u3063\u305f\u3001\u6700\u3082\u30b7\u30f3\u30d7\u30eb\u306a\u7d50\u5408\u30d1\u30bf\u30fc\u30f3\u3092\u30de\u30b9\u30bf\u30fc\u3057\u307e\u3057\u3087\u3046\u3002\u3053\u306e\u6bb5\u968e\u3067\u306f<code>LEFT JOIN<\/code>\u306f\u4e00\u65e6\u5fd8\u308c\u3066OK\u3067\u3059\u3002<\/p>\n<p><strong>\u30b9\u30c6\u30c3\u30d7\u2462\uff1aGROUP BY \u3068 COUNT \u3067\u300c\u96c6\u8a08\u306e\u7b2c\u4e00\u6b69\u300d\u3092\u8e0f\u307f\u51fa\u3059<\/strong><br \/>\n\u6700\u5f8c\u306b\u3001\u300c\u90e8\u7f72\u3054\u3068\u306e\u4eba\u6570\u300d\u300c\u5546\u54c1\u30ab\u30c6\u30b4\u30ea\u3054\u3068\u306e\u54c1\u6570\u300d\u306a\u3069\u3001<code>GROUP BY<\/code>\u3068<code>COUNT(*)<\/code>\u3092\u4f7f\u3063\u305f\u7c21\u5358\u306a\u96c6\u8a08\u306b\u6311\u6226\u3057\u307e\u3059\u3002\u307e\u305a\u306f\u300c\u30b0\u30eb\u30fc\u30d7\u5316\u3057\u3066\u6570\u3048\u308b\u300d\u3068\u3044\u3046\u611f\u899a\u3092\u63b4\u3080\u3053\u3068\u304c\u76ee\u6a19\u3067\u3059\u3002<\/p>\n<h4>\u30b3\u30fc\u30b92\uff1a\u5f97\u70b9\u529b\u76e4\u77f3\uff01\u5fdc\u7528\u30de\u30b9\u30bf\u30fc\u30b3\u30fc\u30b9 (\u4e2d\u7d1a\u8005\u5411\u3051)<\/h4>\n<p><strong>\u30b4\u30fc\u30eb\uff1a<\/strong>SQL\u3092\u5b89\u5b9a\u3057\u305f\u5f97\u70b9\u6e90\u306b\u5909\u3048\u3001\u5408\u683c\u3092\u76e4\u77f3\u306b\u3059\u308b\u3002<\/p>\n<hr>\n<p><strong>\u30b9\u30c6\u30c3\u30d7\u2460\uff1aLEFT JOIN \u3068 \u526f\u554f\u3044\u5408\u308f\u305b(IN\/EXISTS)\u3092\u4f7f\u3044\u5206\u3051\u308b<\/strong><br \/>\n<code>INNER JOIN<\/code>\u3068\u306e\u9055\u3044\u306f\u4f55\u304b\uff1f<code>IN<\/code>\u3068<code>EXISTS<\/code>\u306e\u3069\u3061\u3089\u304c\u9069\u5207\u304b\uff1f\u904e\u53bb\u554f\u3092\u984c\u6750\u306b\u3001\u300c\u306a\u305c\u3001\u3053\u306e\u554f\u984c\u3067\u306f\u3053\u3061\u3089\u3092\u4f7f\u3046\u306e\u304b\u300d\u3092\u81ea\u5206\u306e\u8a00\u8449\u3067\u8aac\u660e\u3067\u304d\u308b\u30ec\u30d9\u30eb\u3092\u76ee\u6307\u3057\u307e\u3057\u3087\u3046\u3002\u672c\u8a18\u4e8b\u306e\u601d\u8003\u30c8\u30ec\u30fc\u30b9\u304c\u5f79\u306b\u7acb\u3064\u306f\u305a\u3067\u3059\u3002<\/p>\n<p><strong>\u30b9\u30c6\u30c3\u30d7\u2461\uff1aHAVING \u3068 CASE\u5f0f\u3092\u6b66\u5668\u306b\u3059\u308b<\/strong><br \/>\n\u300c\u96c6\u8a08\u7d50\u679c\u306b\u5bfe\u3059\u308b\u7d5e\u308a\u8fbc\u307f(<code>HAVING<\/code>)\u300d\u3068\u300c\u6761\u4ef6\u306b\u5fdc\u3058\u305f\u8868\u793a\u306e\u5207\u308a\u66ff\u3048(<code>CASE<\/code>)\u300d\u306f\u3001\u5fdc\u7528\u60c5\u5831SQL\u306e\u983b\u51fa\u5fdc\u7528\u30d1\u30bf\u30fc\u30f3\u3067\u3059\u3002\u3053\u308c\u3089\u306e\u30ad\u30fc\u30ef\u30fc\u30c9\u304c\u767b\u5834\u3059\u308b\u904e\u53bb\u554f\u3092\u91cd\u70b9\u7684\u306b\u89e3\u304d\u3001\u81ea\u7531\u81ea\u5728\u306b\u4f7f\u3044\u3053\u306a\u305b\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><strong>\u30b9\u30c6\u30c3\u30d7\u2462\uff1a\u6642\u9593\u3092\u8a08\u3063\u3066\u904e\u53bb\u554f\u3092\u89e3\u304d\u3001\u601d\u8003\u30d7\u30ed\u30bb\u30b9\u3092\u518d\u73fe\u3059\u308b<\/strong><br \/>\n\u6700\u7d42\u30b9\u30c6\u30c3\u30d7\u306f\u3001\u672c\u756a\u540c\u69d8\u306e\u30d7\u30ec\u30c3\u30b7\u30e3\u30fc\u306e\u4e2d\u3067\u3001\u3053\u308c\u307e\u3067\u5b66\u3093\u3060\u601d\u8003\u30d7\u30ed\u30bb\u30b9\u3092\u5b9f\u8df5\u3059\u308b\u3053\u3068\u3067\u3059\u3002\u6642\u9593\u3092\u8a08\u3063\u3066\u554f\u984c\u3092\u89e3\u304d\u3001\u7b54\u3048\u5408\u308f\u305b\u306e\u969b\u306b\u306f\u300c\u306a\u305c\u305d\u306e\u7b54\u3048\u306b\u306a\u3063\u305f\u304b\u300d\u306e\u7b4b\u9053\u3092\u3001\u81ea\u5206\u306e\u982d\u3067\u518d\u73fe\u3067\u304d\u308b\u304b\u3092\u78ba\u8a8d\u3057\u307e\u3057\u3087\u3046\u3002\u3053\u308c\u304c\u3067\u304d\u308c\u3070\u3001\u3042\u306a\u305f\u306f\u3082\u3046SQL\u30de\u30b9\u30bf\u30fc\u3067\u3059\u3002<\/p>\n<h3>9. \u7406\u89e3\u5ea6\u30c1\u30a7\u30c3\u30af\uff06\u30c1\u30e3\u30ec\u30f3\u30b8\u30af\u30a4\u30ba<\/h3>\n<p>\u304a\u75b2\u308c\u69d8\u3067\u3057\u305f\uff01\u3044\u3088\u3044\u3088\u6700\u7d42\u95a2\u9580\u3067\u3059\u3002\u3053\u3053\u3067\u3042\u306a\u305f\u306eSQL\u8aad\u89e3\u529b\u304c\u3069\u308c\u3060\u3051\u5411\u4e0a\u3057\u305f\u304b\u3001\u8155\u8a66\u3057\u3092\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u672c\u8a18\u4e8b\u3067\u89e3\u8aac\u3057\u305f\u300c\u601d\u8003\u6cd5\u300d\u3092\u983c\u308a\u306b\u3001\u6b63\u89e3\u3092\u5c0e\u304d\u51fa\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h4>\u7b2c1\u554f\uff1aJOIN\u306e\u4f7f\u3044\u5206\u3051<\/h4>\n<p><strong>\u3010\u8981\u4ef6\u3011<\/strong>\u5168\u90e8\u7f72\u306e\u300c\u90e8\u7f72\u540d\u300d\u3068\u3001\u5404\u90e8\u7f72\u306b\u6240\u5c5e\u3059\u308b\u300c\u793e\u54e1\u6570\u300d\u3092\u4e00\u89a7\u8868\u793a\u3057\u305f\u3044\u3002\u307e\u3060\u793e\u54e1\u304c\u4e00\u4eba\u3082\u6240\u5c5e\u3057\u3066\u3044\u306a\u3044\u90e8\u7f72\u3082\u30ea\u30b9\u30c8\u306b\u542b\u3081\u3001\u305d\u306e\u5834\u5408\u3001\u793e\u54e1\u6570\u306f0\u3068\u8868\u793a\u3059\u308b\u3053\u3068\u3002<\/p>\n<p><strong>\u3010\u30c6\u30fc\u30d6\u30eb\u3011<\/strong><br \/>\n\u30fb\u90e8\u7f72\u30de\u30b9\u30bf (<u>\u90e8\u7f72\u30b3\u30fc\u30c9<\/u>, \u90e8\u7f72\u540d)<br \/>\n\u30fb\u793e\u54e1\u30de\u30b9\u30bf (<u>\u793e\u54e1\u756a\u53f7<\/u>, \u6c0f\u540d, \u90e8\u7f72\u30b3\u30fc\u30c9)<\/p>\n<p><strong>\u3010SQL\u6587\u3011<\/strong><\/p>\n<pre><code>\nSELECT\n    T1.\u90e8\u7f72\u540d,\n    COUNT(T2.\u793e\u54e1\u756a\u53f7) AS \u793e\u54e1\u6570\nFROM\n    \u90e8\u7f72\u30de\u30b9\u30bf AS T1 <strong>[ \u30a2 ]<\/strong> \u793e\u54e1\u30de\u30b9\u30bf AS T2\n    ON T1.\u90e8\u7f72\u30b3\u30fc\u30c9 = T2.\u90e8\u7f72\u30b3\u30fc\u30c9\nGROUP BY\n    T1.\u90e8\u7f72\u540d;\n<\/code><\/pre>\n<p><strong>\u7a7a\u6b04 [ \u30a2 ] \u306b\u5165\u308b\u6700\u3082\u9069\u5207\u306a\u53e5\u306f\u3069\u308c\u304b\uff1f<\/strong><\/p>\n<ol>\n<li>INNER JOIN<\/li>\n<li>LEFT JOIN<\/li>\n<li>RIGHT JOIN<\/li>\n<li>CROSS JOIN<\/li>\n<\/ol>\n<hr>\n<h4>\u7b2c2\u554f\uff1aHAVING\u3068WHERE\u306e\u9055\u3044<\/h4>\n<p><strong>\u3010\u8981\u4ef6\u3011<\/strong>\u5546\u54c1\u30ab\u30c6\u30b4\u30ea\u3054\u3068\u306b\u5e73\u5747\u5358\u4fa1\u3092\u8a08\u7b97\u3057\u3001\u305d\u306e\u5e73\u5747\u5358\u4fa1\u304c5,000\u5186\u4ee5\u4e0a\u306e\u30ab\u30c6\u30b4\u30ea\u3060\u3051\u3092\u8868\u793a\u3057\u305f\u3044\u3002<\/p>\n<p><strong>\u3010\u30c6\u30fc\u30d6\u30eb\u3011<\/strong><br \/>\n\u30fb\u5546\u54c1\u30de\u30b9\u30bf (<u>\u5546\u54c1\u30b3\u30fc\u30c9<\/u>, \u5546\u54c1\u540d, \u30ab\u30c6\u30b4\u30ea, \u5358\u4fa1)<\/p>\n<p><strong>\u3010SQL\u6587\u3011<\/strong><\/p>\n<pre><code>\nSELECT\n    \u30ab\u30c6\u30b4\u30ea,\n    AVG(\u5358\u4fa1) AS \u5e73\u5747\u5358\u4fa1\nFROM\n    \u5546\u54c1\u30de\u30b9\u30bf\nGROUP BY\n    \u30ab\u30c6\u30b4\u30ea\n<strong>[ \u30a4 ]<\/strong>\n    AVG(\u5358\u4fa1) >= 5000;\n<\/code><\/pre>\n<p><strong>\u7a7a\u6b04 [ \u30a4 ] \u306b\u5165\u308b\u6700\u3082\u9069\u5207\u306a\u53e5\u306f\u3069\u308c\u304b\uff1f<\/strong><\/p>\n<ol>\n<li>WHERE<\/li>\n<li>HAVING<\/li>\n<li>AND<\/li>\n<li>ON<\/li>\n<\/ol>\n<hr>\n<h3>\u89e3\u7b54\u3068\u89e3\u8aac<\/h3>\n<p>\u2193\uff08\u4e0b\u306b\u30b9\u30af\u30ed\u30fc\u30eb\u3057\u3066\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\uff09\u2193<\/p>\n<p><\/p>\n<hr>\n<h4>\u7b2c1\u554f\u306e\u89e3\u7b54\u30fb\u89e3\u8aac<\/h4>\n<p><strong>\u6b63\u89e3\uff1a2. LEFT JOIN<\/strong><\/p>\n<p><strong>\u3010\u601d\u8003\u30d7\u30ed\u30bb\u30b9\u3011<\/strong><br \/>\n\u3053\u306e\u554f\u984c\u306e\u6700\u5927\u306e\u30d2\u30f3\u30c8\u306f\u3001\u300c<strong>\u307e\u3060\u793e\u54e1\u304c\u4e00\u4eba\u3082\u6240\u5c5e\u3057\u3066\u3044\u306a\u3044\u90e8\u7f72\u3082\u30ea\u30b9\u30c8\u306b\u542b\u3081<\/strong>\u300d\u3068\u3044\u3046\u4e00\u6587\u3067\u3059\u3002\u3053\u308c\u306f\u3001\u300c\u4e3b\u8ef8\u3068\u306a\u308b\u30c6\u30fc\u30d6\u30eb\u306f<strong>\u90e8\u7f72\u30de\u30b9\u30bf<\/strong>\u3067\u3042\u308a\u3001\u305d\u306e\u5168\u4ef6\u3092\u8868\u793a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u300d\u3068\u3044\u3046\u3053\u3068\u3092\u610f\u5473\u3057\u307e\u3059\u3002<br \/>\n\u5de6\u5074\uff08<code>FROM<\/code>\u53e5\u306e\u6700\u521d\uff09\u306b\u66f8\u304b\u308c\u305f<code>\u90e8\u7f72\u30de\u30b9\u30bf<\/code>\u3092\u57fa\u6e96\u306b\u3001\u305d\u308c\u306b\u7d10\u3065\u304f<code>\u793e\u54e1\u30de\u30b9\u30bf<\/code>\u306e\u60c5\u5831\u3092\u7d50\u5408\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u305f\u3081\u3001\u5de6\u5074\u3092\u6b63\u3068\u3059\u308b<strong><code>LEFT JOIN<\/code><\/strong>\u304c\u6b63\u89e3\u3068\u306a\u308a\u307e\u3059\u3002<br \/>\n\u3082\u3057<code>INNER JOIN<\/code>\u3092\u9078\u3076\u3068\u3001\u793e\u54e1\u304c\u4e00\u4eba\u3082\u3044\u306a\u3044\u90e8\u7f72\uff08\u793e\u54e1\u30de\u30b9\u30bf\u306b\u5bfe\u5fdc\u3059\u308b\u30ec\u30b3\u30fc\u30c9\u304c\u306a\u3044\u90e8\u7f72\uff09\u306f\u7d50\u679c\u304b\u3089\u9664\u5916\u3055\u308c\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<h4>\u7b2c2\u554f\u306e\u89e3\u7b54\u30fb\u89e3\u8aac<\/h4>\n<p><strong>\u6b63\u89e3\uff1a2. HAVING<\/strong><\/p>\n<p><strong>\u3010\u601d\u8003\u30d7\u30ed\u30bb\u30b9\u3011<\/strong><br \/>\n\u7a7a\u6b04 [\u30a4] \u306e\u76f4\u5f8c\u306b\u3042\u308b\u6761\u4ef6\u5f0f <code>AVG(\u5358\u4fa1) >= 5000<\/code> \u306b\u6ce8\u76ee\u3057\u307e\u3059\u3002<code>AVG()<\/code>\u306f\u96c6\u7d04\u95a2\u6570\u3067\u3059\u3002<br \/>\n\u30bb\u30af\u30b7\u30e7\u30f34-3\u306e\u9244\u5247\u3092\u601d\u3044\u51fa\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u300c<strong>\u96c6\u7d04\u95a2\u6570\u3092\u4f7f\u3063\u305f\u6761\u4ef6\u5f0f\u306f\u3001<code>HAVING<\/code>\u53e5\u306b\u3057\u304b\u8a18\u8ff0\u3067\u304d\u306a\u3044<\/strong>\u300d\u3067\u3057\u305f\u306d\u3002<br \/>\n<code>WHERE<\/code>\u53e5\u306f<code>GROUP BY<\/code>\u3067\u30b0\u30eb\u30fc\u30d7\u5316\u3059\u308b\u524d\u306e\u300c\u500b\u4eba\u6226\u300d\u30d5\u30a3\u30eb\u30bf\u30fc\u3067\u3042\u308a\u3001\u96c6\u7d04\u95a2\u6570\u3092\u4f7f\u3046\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093\u3002<code>GROUP BY<\/code>\u5f8c\u306e\u300c\u56e3\u4f53\u6226\u300d\u30d5\u30a3\u30eb\u30bf\u30fc\u3067\u3042\u308b<strong><code>HAVING<\/code><\/strong>\u53e5\u304c\u3001\u3053\u306e\u5834\u9762\u3067\u4f7f\u3046\u3079\u304d\u552f\u4e00\u306e\u6b63\u89e3\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u306f\u3058\u3081\u306b\u3001\u3053\u306e\u8a18\u4e8b\u304c\u76ee\u6307\u3059\u30b4\u30fc\u30eb\u3092\u5171\u6709\u3055\u305b\u3066\u304f\u3060\u3055\u3044\u3002 \u3053\u306e\u8a18\u4e8b\u306f\u3001\u5358\u306a\u308bSQL\u69cb\u6587\u306e\u89e3\u8aac\u66f8\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u4e16\u306e\u4e2d\u306b\u306f\u7d20\u6674\u3089\u3057\u3044SQL\u306e\u5165\u9580\u66f8\u304c\u305f\u304f\u3055\u3093\u3042\u308a\u307e\u3059\u3057\u3001\u5404\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u5f79\u5272\u3092\u899a\u3048\u308b\u3053\u3068\u306f\u3082\u3061 &#8230; <\/p>\n","protected":false},"author":2,"featured_media":5098,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","columnck":"","stmeta_robots":"index, follow","st_titlewords":"","st_title_extra":"","st_keywords":"","st_description":"","st_display_ad_mark":"","st_display_ad_mark_hide":"","textcopyck":"","st_copyright":"","st_copyurl":"","eyecatch_set":"","st_youtube_url":"","st_youtube_eyecatch":"","headerwidget_set":"","updatewidget_set":"","kanrenwidget_set":"","ikkatuwidget_set":"","koukoku_set":"","auto_adsense_koukoku_set":"","st_redirect":"","st_redirect_url_as_canonical":"","st_redirect_pvm_do_not_track":"","post_data_updatewidget_set":"","st_post_header_under_bg":"","st_twitter_tag":"","affinger_note":"","rankdisplayck":"","st_head_code":"","st_footer_code":"","st_post_header_under_code":"","_st_toc_override":false,"_st_toc_settings":[]},"categories":[3],"tags":[6],"class_list":["post-5097","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ipa","tag-6"],"_links":{"self":[{"href":"https:\/\/sky-peace.net\/certified\/wp-json\/wp\/v2\/posts\/5097","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sky-peace.net\/certified\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sky-peace.net\/certified\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sky-peace.net\/certified\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/sky-peace.net\/certified\/wp-json\/wp\/v2\/comments?post=5097"}],"version-history":[{"count":0,"href":"https:\/\/sky-peace.net\/certified\/wp-json\/wp\/v2\/posts\/5097\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sky-peace.net\/certified\/wp-json\/wp\/v2\/media\/5098"}],"wp:attachment":[{"href":"https:\/\/sky-peace.net\/certified\/wp-json\/wp\/v2\/media?parent=5097"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sky-peace.net\/certified\/wp-json\/wp\/v2\/categories?post=5097"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sky-peace.net\/certified\/wp-json\/wp\/v2\/tags?post=5097"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}