select year(ShippedDate) as 年份, sum ( case when month(ShippedDate) in (1,2,3)) then count(accid) as 销售总份数,sum(account) as 销售总金额 else 0 ) as 第一季度
from EM where ShippedDate like'2010?' group by year(ShippedDate) order by year(ShippedDate)
请各位帮忙看看,我这么写有问题吗?
------解决方案--------------------
------解决方案--------------------
SQL code
select year(ShippedDate) as 年份,
sum
(
case when
month(ShippedDate) in (1,2,3))
then count(accid) end as 销售总份数,sum(account) as 销售总金额 --这里的end忘记了哦
else 0
) as 第一季度
from EM
where ShippedDate like'2010%' --还有这里的? 要用%
group by year(ShippedDate)
order by year(ShippedDate)