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')
如对本文有疑问, 点击进行留言回复!!
linux 安装 MySql 5.7.20 一主多从配置【亲测】 - 之三
Linux: ------ MySQL 基于MyCat的主从复制 读写分离
lower_case_table_names=1 启动报错 mysql8.0
全网最全经典卷积神经网络架构汇总——深度学习之ILSVRC竞赛(ImageNet竞赛)优胜网络结构
网友评论