当前位置: 移动技术网 > IT编程>数据库>Mysql > MySql查询当年1-12月数据

MySql查询当年1-12月数据

2019年04月19日  | 移动技术网IT编程  | 我要评论

mysql查询当年1-12月数据。

select count(*) as jantradingvolume, coalesce(sum(tt.amount),0) as janamount,

(select count(*) from tt_trade tt

where date_format(tt.creationtime,'%y-%m') = concat(year(now()),'-02')) as febtradingvolume,

(select coalesce(sum(tt.amount),0) from tt_trade tt

where date_format(tt.creationtime,'%y-%m') = concat(year(now()),'-02')) as febamount,

(select count(*) from tt_trade tt

where date_format(tt.creationtime,'%y-%m') = concat(year(now()),'-03')) as martradingvolume,

(select coalesce(sum(tt.amount),0) from tt_trade tt

where date_format(tt.creationtime,'%y-%m') = concat(year(now()),'-03')) as maramount,

(select count(*) from tt_trade tt

where date_format(tt.creationtime,'%y-%m') = concat(year(now()),'-04')) as aprtradingvolume,

(select coalesce(sum(tt.amount),0) from tt_trade tt

where date_format(tt.creationtime,'%y-%m') = concat(year(now()),'-04')) as apramount,

(select count(*) from tt_trade tt

where date_format(tt.creationtime,'%y-%m') = concat(year(now()),'-05')) as maytradingvolume,

(select coalesce(sum(tt.amount),0) from tt_trade tt

where date_format(tt.creationtime,'%y-%m') = concat(year(now()),'-05')) as mayamount,

(select count(*) from tt_trade tt

where date_format(tt.creationtime,'%y-%m') = concat(year(now()),'-06')) as juntradingvolume,

(select coalesce(sum(tt.amount),0) from tt_trade tt

where date_format(tt.creationtime,'%y-%m') = concat(year(now()),'-06')) as junamount,

(select count(*) from tt_trade tt

where date_format(tt.creationtime,'%y-%m') = concat(year(now()),'-07')) as jultradingvolume,

(select coalesce(sum(tt.amount),0) from tt_trade tt

where date_format(tt.creationtime,'%y-%m') = concat(year(now()),'-07')) as julamount,

(select count(*) from tt_trade tt

where date_format(tt.creationtime,'%y-%m') = concat(year(now()),'-08')) as augtradingvolume,

(select coalesce(sum(tt.amount),0) from tt_trade tt

where date_format(tt.creationtime,'%y-%m') = concat(year(now()),'-08')) as augamount,

(select count(*) from tt_trade tt

where date_format(tt.creationtime,'%y-%m') = concat(year(now()),'-09')) as septradingvolume,

(select coalesce(sum(tt.amount),0) from tt_trade tt

where date_format(tt.creationtime,'%y-%m') = concat(year(now()),'-09')) as sepamount,

(select count(*) from tt_trade tt

where date_format(tt.creationtime,'%y-%m') = concat(year(now()),'-10')) as octtradingvolume,

(select coalesce(sum(tt.amount),0) from tt_trade tt

where date_format(tt.creationtime,'%y-%m') = concat(year(now()),'-10')) as octamount,

(select count(*) from tt_trade tt

where date_format(tt.creationtime,'%y-%m') = concat(year(now()),'-11')) as novtradingvolume,

(select coalesce(sum(tt.amount),0) from tt_trade tt

where date_format(tt.creationtime,'%y-%m') = concat(year(now()),'-11')) as novamount,

(select count(*) from tt_trade tt

where date_format(tt.creationtime,'%y-%m') = concat(year(now()),'-12')) as dectradingvolume,

(select coalesce(sum(tt.amount),0) from tt_trade tt

where date_format(tt.creationtime,'%y-%m') = concat(year(now()),'-12')) as decamount

from tt_trade tt

where date_format(tt.creationtime,'%y-%m') = concat(year(now()),'-01')

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网