Home >Backend Development >PHP Tutorial > 问一个mysql,group by 日期分组查询的有关问题

问一个mysql,group by 日期分组查询的有关问题

WBOY
WBOYOriginal
2016-06-13 13:44:47962browse

问一个mysql,group by 日期分组查询的问题
数据表字段为datetime类型的,保存的值2009-02-10 12:20:11
我想写一个按日数来查询的sql
就是当天有多少条记录
就是有两条记录,日期分别为2009-02-10 12:20:11,2009-02-10 22:20:11
结果显示
2009-02-10 数量 2

知道的朋友讲下,先谢了



------解决方案--------------------

SQL code

select count(left(shijian,'10')) as sl,left(shijian,'10') as sj from tablea group by sj <div class="clear">
                 
              
              
        
            </div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn