34,588
社区成员
发帖
与我相关
我的任务
分享
select [date],
Money1=Sum(Case InOrOut When 1 then [Money] else 0 end),
Money2=Sum(Case InOrOut When 0 then [Money] else 0 end),
Times
from tb
group by [date],Times
SELECT
CONVert(varchar(10),date,120)as date,
sum(case when inorout=1 then Money else 0 end) Money1,
sum(case when inorout=0 then Money else 0 end) Money2,TIMES
from tb group by CONVert(varchar(10),date,120),TIMES
order by 1 DESC
SELECT
CONVert(varchar(10),date,120)as date,
sum(case when inorout=1 then Money else 0 end) Money1,
sum(case when inorout=0 then Money else 0 end) Money2
from tb group by CONVert(varchar(10),date,120)
order by 1 DESC
select
date,
sum(case InOrOut when 0 then [money] else 0 end) as 'Money1',
sum(case InOrOut when 1 then [money] else 0 end) as 'Money2',
times
from
tb
group by
date,times