mysql group by column1,column2' Desc \ | asc'没有错误

时间:2018-02-23 10:50:43

标签: mysql mariadb

当我在那里运行以下查询时没有错误。请注意查询上的DESC。

select date(created) date,
       count(distinct some_id) subsccount,
       type
    from  sometable
    group by date,type DESC
    limit 5

1 个答案:

答案 0 :(得分:2)

正如select syntax上的MySQL文档所说:

  

MySQL扩展了GROUP BY子句,以便您也可以指定ASC和   在子句中命名的列之后的DESC:

SELECT a, COUNT(b) FROM test_table GROUP BY a DESC;