关键词不能为空

当前您在: 主页 > 英语 >

efficiencySQL语句统计每天、每月、每年的_数据

作者:高考题库网
来源:https://www.bjmy2z.cn/gaokao
2021-01-21 13:26
tags:

一模一样-efficiency

2021年1月21日发(作者:anachronism)
1.

//
按天统计

2.

select count(dataid) as
每天操作数量
, sum()
3.

from
4.

where
5.

group by trunc(createtime, 'DD'))
6.

//
按自然周统计

7.

select to_char(date,'iw'),sum()
8.

from
9.

where
10.

group by to_char(date,'iw')
11.

//
按自然月统计

12.

select to_char(date,'mm'),sum()
13.

from
14.

where
15.

group by to_char(date,'mm')
16.

//
按季统计

17.

select to_char(date,'q'),sum()
18.

from
19.

where
20.

group by to_char(date,'q')
21.

//
按年统计

22.

select to_char(date,'yyyy'),sum()
23.

from
24.

where
25.

group by to_char(date,'yyyy')

SQL
语句统计每天、每月、每年的

数据



1
、每年

select year(ordertime)
年,

sum(Total)
销售合计

from
订单表

group by year(ordertime)

2
、每月

select year(ordertime)
年,

month(ordertime)

,
sum(Total)
销售合计

from
订单表

group by year(ordertime)


month(ordertime

3
、每日

select year(ordertime)
年,

month(ordertime)

,
day(ordertime)
日,

sum(Total)
销售合计

from
订单表

group by year(ordertime)


month(ordertime),
day(ordertime)

另外每日也可以这样
:
select convert(char(8),ordertime,112) dt


sum(Total)
销售合计

from
订单表

group by convert(char(8),ordertime,112)



sql


如何统计查询一个月中每天的记录

怎么写啊?写出来啊!


比如说要查
2010

3
月份每天的记录

提问者:

Java_Travler
-



最佳答案

select count(*),substr(,1,10)

from table t where

like '2010-03%' group by
substr(,1,10)

一模一样-efficiency


一模一样-efficiency


一模一样-efficiency


一模一样-efficiency


一模一样-efficiency


一模一样-efficiency


一模一样-efficiency


一模一样-efficiency



本文更新与2021-01-21 13:26,由作者提供,不代表本网站立场,转载请注明出处:https://www.bjmy2z.cn/gaokao/544292.html

SQL语句统计每天、每月、每年的_数据的相关文章