表结构
表结构
在页面按照类型分类,
sql实现:
s
q
l
1
,
占
位
符
,
具
体
截
取
时
间
字
段
。
s
e
l
e
c
t
S
U
B
S
T
R
I
N
G
(
a
.
t
j
r
q
,
1
,
{sql1},占位符,具体截取时间字段。 select SUBSTRING(a.tjrq,1,
sql1,占位符,具体截取时间字段。selectSUBSTRING(a.tjrq,1,{sql1}) as tjrq, tj_type,sum(a.tj_yfknum) tj_yfknum,sum(a.tj_yqsnum) tj_yqsnum,sum(a.tj_wqsnum) tj_wqsnum from
(select tjrq,tj_type,
sum(case when tj_yfknum= ‘’ or tj_yfknum is null then 0 else CAST (tj_yfknum AS NUMERIC(10,0) ) end ) tj_yfknum,
sum(case when tj_yqsnum= ''or tj_yqsnum is null then 0 else CAST (tj_yqsnum AS NUMERIC(10,0) ) end ) tj_yqsnum,
sum(case when tj_wqsnum= ''or tj_wqsnum is null then 0 else CAST (tj_wqsnum AS NUMERIC(10,0) ) end ) tj_wqsnum
from tj_send where tjrq BETWEEN #{start_time} AND #{end_time} group by tj_type,tjrq)a group by SUBSTRING(a.tjrq,1,${sql1}),tj_type
order by tjrq desc
效果:
实现效果
sqlserver 实现复杂sql
最新推荐文章于 2022-02-17 18:12:31 发布