{"type":"rich","categories":[],"blog_url":"https://yut.hatenablog.com/","title":"mysql\u3067group\u6bce\u306eTop-K\u884c\u3092\u53d6\u5f97\u3059\u308b\u65b9\u6cd5","published":"2015-12-31 18:29:42","description":"How to select the first/least/max row per group in SQL \u00b7 Baron Schwartz's Blog mysql\u3092\u7528\u3044\u305f\u7279\u5b9a\u306egroup\u306b\u6240\u5c5e\u3059\u308b\u884c\u3092\u4e00\u5b9a\u6570\u305a\u3064(\u3082\u3057\u304f\u306f\u4f55\u304b\u3057\u3089\u3067sort\u3055\u308c\u305fTop-K\u884c)\u53d6\u308a\u51fa\u3057\u305f\u3044\u3068\u3044\u3046\u554f\u984c\u304c\u3042\u308b\u3002\u3053\u308c\u3057\u304d\u306e\u4e8b\u3001\u5358\u7d14\u306agroup by\u3092\u4f7f\u3063\u3066\u7c21\u5358\u306b\u89e3\u304d\u305f\u3044\u5185\u5bb9\u3067\u3042\u308b\u304c\u3061\u3087\u3063\u3068\u3057\u305f\u30c6\u30af\u30cb\u30c3\u30af\u3092\u5fc5\u8981\u3068\u3059\u308b\u3002\u8abf\u3079\u305f\u3068\u3053\u308d\u4ee5\u4e0b\u306e\u89e3\u6c7a\u65b9\u6cd5\u304c\u3042\u308b\u3002 1. union all\u3092\u4f7f\u3063\u3066group\u6bce\u306b\u62bd\u51fa\u3057\u305f\u7d50\u679c\u3092\u7d50\u5408\u3002 2. table\u3092group\u3067\u81ea\u5df1\u7d50\u5408\u3057\u7279\u5b9a\u884c\u6570\u53d6\u5f97\u3002 3. session\u56fa\u6709\u306e\u30e6\u30fc\u30b6\u5b9a\u7fa9\u5909\u6570\u2026","image_url":null,"provider_url":"https://hatena.blog","height":"190","width":"100%","blog_title":"Y's note","author_name":"yutakikuchi","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fyut.hatenablog.com%2Fentry%2F2015%2F12%2F31%2F182942\" title=\"mysql\u3067group\u6bce\u306eTop-K\u884c\u3092\u53d6\u5f97\u3059\u308b\u65b9\u6cd5 - Y&#39;s note\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","provider_name":"Hatena Blog","author_url":"https://blog.hatena.ne.jp/yutakikuchi/","version":"1.0","url":"https://yut.hatenablog.com/entry/2015/12/31/182942"}