Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
与MySQL中的GROUPBY不同_Mysql_Sql_Group By_Distinct - Fatal编程技术网

与MySQL中的GROUPBY不同

与MySQL中的GROUPBY不同,mysql,sql,group-by,distinct,Mysql,Sql,Group By,Distinct,如果我选择了不同的值,但我对结果进行了分组,那么这些值是仅在每个分组中是不同的,还是在所有分组中都是不同的 例如: month | id | 01 | 17 01 | 17 01 | 19 04 | 17 04 | 20 如果我跑 select month, count(distinct id) from table group by month 这两个月我能拿到多少钱?你每个月能拿到2英镑 这是一个显示结果的示例。为什么不试试呢?在分组中是不同

如果我选择了不同的值,但我对结果进行了分组,那么这些值是仅在每个分组中是不同的,还是在所有分组中都是不同的

例如:

month | id
      |
  01  | 17 
  01  | 17 
  01  | 19
  04  | 17
  04  | 20
如果我跑

select month, count(distinct id)
from table
group by month

这两个月我能拿到多少钱?

你每个月能拿到2英镑


这是一个显示结果的示例。

为什么不试试呢?在分组中是不同的。您将获得01->2和02->2,您可以使用它们来构建架构并在浏览器中全部试用。@sgedes我认为有一个问题可以供其他人参考。但你是对的,我本可以回答我自己的问题。