做一个电子商务,需要对多个字段做查询统计。题目见一楼,请指教!
场景:有TTrans(交易记录表)一张,关键字段有FID(主键),FCardNo(卡号),FTotalAmt(交易总金额),FTransDate(交易时间)
统计:统计出2013年每月的营业总金额、发生交易的卡数,交易记录数量。
附:先贴出小弟写的一条统计语句,求指点

declare @Year int 
set @Year = 2013 
select m as [FMonth],
sum(
	case when datepart(month,t1.FTransDate ) = m then t1.FTotalAmt 
	else 0 
	end
) as [FTotalAmt]
from TTrans t1
, (
	select 1 m 
	union all select 2 
	union all select 3 
	union all select 4 
	union all select 5 
	union all select 6 
	union all select 7 
	union all select 8 
	union all select 9 
	union all select 10 
	union all select 11 
	union all select 12  
) [month] 
where @Year=year(t1.FTransDate) 
group by [month].m  
order by [FMonth] asc
              
------解决方案--------------------贴到sql 里运行看看哦。 [month]   t1 关系好像没建立吧。