{"id":92829,"date":"2020-03-21T05:49:45","date_gmt":"2020-03-20T21:49:45","guid":{"rendered":"http:\/\/4563.org\/?p=92829"},"modified":"2020-03-21T05:49:45","modified_gmt":"2020-03-20T21:49:45","slug":"mysql-select-%e7%9a%84%e6%9f%a5%e8%af%a2%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=92829","title":{"rendered":"mysql select \u7684\u67e5\u8be2\u95ee\u9898"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  mysql select \u7684\u67e5\u8be2\u95ee\u9898               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : 6260628 <\/span>  <span><i><\/i> 29<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u641c\u4e86\u534a\u5929\u4e0d\u77e5\u9053\u641c\u4ec0\u4e48\u5173\u952e\u5b57\uff0c\u8bf7\u6559\u4e00\u4e0b\u5404\u4f4d mysql \u91cc\u9762 select a,b from table group by a \u8fd9\u79cd\u8bed\u53e5\uff0cb \u7684\u53d6\u503c\u903b\u8f91\u662f\u4ec0\u4e48\uff1f<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>17<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"987062\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : gz911122 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u79cd sql \u5728 5.6 \u4ee5\u4e0a\u662f\u4e0d\u5141\u8bb8\u7684<br \/>select \u7684\u6761\u4ef6\u9700\u8981\u5728 group by \u91cc\u9762,\u6216\u8005\u7528 max min \u4e4b\u7c7b\u7684\u51fd\u6570\u5305\u88f9\u8d77\u6765                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"987063\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : 6260628 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @gz911122 \u6211\u7684 sql \u7248\u672c\u662f 5.6 \u4ee5\u4e0b\uff0c\u4e4b\u524d\u522b\u7684\u540c\u4e8b\u6709\u6309\u8fd9\u4e2a\u8bed\u6cd5\u5199\u8fc7 sql\uff0c\u800c\u4e14\u5173\u8054\u4e1a\u52a1\u903b\u8f91\uff0c\u6240\u4ee5\u8bf7\u544a\u77e5\u8fd9\u4e2a\u53d6\u6570\u903b\u8f91                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"987064\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : kr380709959 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @6260628 \u4f60\u8fd9\u4e2a b \u662f\u4e0d\u505a\u4efb\u4f55\u8ba1\u7b97\u5904\u7406\u4e48\uff1f\u6bd4\u5982 count(b)\u6216\u8005\u662f sum(b=value)\u8fd9\u6837\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"987065\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : VictorJing94 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u52a0\u4e2a\u805a\u5408\u51fd\u6570\u5427                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"987066\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : xuanbg <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u79cd\u5199\u6cd5\uff0c\u8fd9\u4e2a b \u53d6\u5230\u7684\u662f\u54ea\u4e00\u884c\u7684 b \u5c31\u662f\u4e2a\u7384\u5b66\u95ee\u9898\u4e86\u2026\u2026\u6b63\u786e\u7684\u5199\u6cd5\u662f\u7528 max(),min(),sum()\u8fd9\u4e9b\u51fd\u6570\u53bb\u53d6\u51fa\u7b26\u5408\u4f60\u9884\u671f\u7684 b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"987067\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : 2379920898 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             A \u5206\u7ec4\u91cc\u9762\u7684 B\uff0c\u548b\u4e86\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"987068\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : skymei <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             B \u5e94\u8be5\u662f\u5339\u914d\u5230\u7684\u7b2c\u4e00\u6761\u5427\uff0c\u4e4b\u524d\u7814\u7a76\u8fc7\uff0c\u5fd8\u4e86&#8230;                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"987069\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : raymanr <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u611f\u89c9\u8fd9\u4e2a\u95ee\u9898\u597d\u50cf\u4e5f\u6ca1\u5565\u597d\u7814\u7a76\u7684, \u672c\u8eab\u5c31\u662f\u4e0d\u89c4\u8303\u7684\u5199\u6cd5&#8230;                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"987070\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : 6260628 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6700\u4e3b\u8981\u7684\u662f\u8d38\u7136\u52a0\u4e86 max \u6216\u8005 min \u6015\u4f1a\u5f71\u54cd\u67e5\u8be2\u903b\u8f91\uff0c\u4e4b\u524d\u5199\u8fd9\u4e2a\u4ee3\u7801\u7684\u5927\u54e5\u5df2\u7ecf\u79bb\u804c\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"987071\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : 6260628 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5f15\u4ee5\u4e3a\u6212\u5427\uff0c\u54ed\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"987072\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : siriussilen <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53d6\u5230\u7684\u662f\u6bcf\u4e2a group \u4e0b\u7684\u7b2c\u4e00\u884c\u6570\u636e                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"987073\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : siriussilen <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u4e2a\u6211\u524d\u4e24\u5929\u521a\u7814\u7a76\u8fc7 \u5728 leetcode \u4e0a\u9762\u7684\u8bc4\u6d4b\u5b9e\u9a8c\u8fc7                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"987074\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : skymei <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             https:\/\/dev.mysql.com\/doc\/refman\/5.6\/en\/group-by-handling.html                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"987075\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : skymei <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @skymei <br \/>\u5b98\u65b9\u6587\u6863\u91cc\u9762\u662f\u8fd9\u4e48\u63cf\u8ff0\u7684 <br \/>The server is free to choose any value from each group, so unless they are the same, the values chosen are nondeterministic.<br \/>\u503c\u4e0d\u786e\u5b9a                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"987076\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : glacer <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u79cd\u5199\u6cd5\u4e0d\u7b26\u5408 SQL \u6807\u51c6\uff0c\u5c5e\u4e8e MySQL \u5f15\u64ce\u7684\u81ea\u5b9a\u4e49\u884c\u4e3a                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"987077\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : hbolive <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             B \u53d6\u5230\u7684\u503c\u53d6\u51b3\u4e8e\u5bf9\u5e94\u7684 A\uff0c\u800c A \u662f\u8fd4\u56de\u7684\u7ed3\u679c\u662f GROUP BY \u7ed3\u679c\u96c6\u4e2d\u7b2c\u4e00\u6761\u6570\u636e\u3002\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"987078\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : littlewing <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             any value\uff0c\u672a\u5b9a\u4e49\u884c\u4e3a\uff0c\u4efb\u4f55\u4e00\u4e2a\u503c\u90fd\u6709\u53ef\u80fd\uff0cmysql \u6ca1\u6709\u660e\u786e\u89c4\u5b9a                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>mysql select \u7684\u67e5\u8be2\u95ee&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/92829"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=92829"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/92829\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=92829"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=92829"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=92829"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}