34,575
社区成员
发帖
与我相关
我的任务
分享
select sum4001-sum4002 from
(select sum(成交价格*成交数量+佣金+印花税+过户费) as sum4002 from tab where 业务标志=4002) a,
(select sum(成交价格*成交数量-佣金-印花税-过户费) as sum4001 from tab where 业务标志=4001) b
select 证券代码
,sum(case when 业务标志=4002 then -(成交价格*成交数量+佣金+印花税+过户费) when 业务标志=4001 then 成交价格*成交数量-佣金-印花税-过户费 end) as [...]
from tab
group by 证券代码
select 证券代码
,sum(case when 业务标志=4002 then 成交价格*成交数量+佣金+印花税+过户费 when 业务标志=4001 then 成交价格*成交数量-佣金-印花税-过户费 end) as [...]
from tab
group by 证券代码