查询上周每天的count数

图片说明

表如上查询上周每天的count数

select count(ordertime) from table group by ordertime

百度SQL语句查询语句

select ordertime,count(*)  条数 from table_name group by ordertime having ordertime<'2017/7/31'

sql server 语句

 select convert(varchar(10),ordertime,120) as tm, count(ordertime) as value
        from table_name  where ordertime BETWEEN '2017-07-24' AND '2017-07-30'
        group by convert(varchar(10),ordertime,120)

每周时间自己算

 select trunc(ordertime,'dd') order_time ,count(*)  all_num from table_name where order_time between to_date('2017-07-24','yyyy-mm-dd') and  o_date('2017-07-30','yyyy-mm-dd') group by trunc(ordertime,'dd')