create view 视图名
as
select wareid,sum(case when istally=1 and isPresent=0 then salenum else 0 end) isNum,sum(case istally=0 and isPresent=0 then salenum else 0 end) notisNum from 表 group by wareid
go
create view 视图名
as
select wareid
,isNum=sum(case istally when 1 then salenum else 0 end)
,notisNum=sum(case istally when 0 then salenum else 0 end)
from 表
group by wareid
create view aa
as
select WareID,sum(case isTally when 1 then SaleNum else 0 end) as isNum,
sum(case isTally when 0 then SaleNum else 0 end) as notisNum
from 表 group by WareID
go
或
create view aa
as
select WareID,sum(SaleNum * isTally) as isNum,
sum(SaleNum * (1-IsTally)) as notisNum
from 表 group by WareID
go
create view aa
as
select WareID,sum(case isTally when 1 then SaleNum else 0 end) as isNum,sum(case isTally when 0 then SaleNum else 0 end) as notisNum from 表 group by WareID
go