数据库教程:MySql查询当年1-12月数据

mysql查询当年1-12月数据。 select count(*) as jantradingvolume, coalesce(sum(tt.amount),0) as jana

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')

需要了解更多数据库技术:MySql查询当年1-12月数据,都可以关注数据库技术分享栏目—计算机技术网(www.ctvol.com)!

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/dtteaching/830859.html

(0)
上一篇 2021年9月19日
下一篇 2021年9月19日

精彩推荐