日期:2014-05-18 浏览次数:20456 次
select * from tb union all select null,null,sum(销售量),店铺 from tb group by 店铺
------解决方案--------------------
SELECT 销售量from tb where 店铺名='A' and 日期=datepart (y,getdate()) SELECT 销售量from tb where 店铺名='B' and 日期=datepart (y,getdate()) SELECT 销售量from tb where 店铺名='C' and 日期=datepart (y,getdate()) SELECT 销售量from tb where 店铺名='D' and 日期=datepart (y,getdate())
------解决方案--------------------
SELECT SUM(销售量) from tb where 店铺名='A' and 日期=datepart (y,getdate()) SELECT SUM(销售量) from tb where 店铺名='B' and 日期=datepart (y,getdate()) SELECT SUM(销售量) from tb where 店铺名='C' and 日期=datepart (y,getdate()) SELECT SUM(销售量) from tb where 店铺名='D' and 日期=datepart (y,getdate())
------解决方案--------------------
select * from tb union all select null,null,sum(销售量),店铺 from tb group by 店铺