700
社区成员
发帖
与我相关
我的任务
分享select 取年(时间),科目编号,科目名称,sum(费用) from table group by 取年(时间) 的格式 select 取年(时间),科目名称,sum(费用) from table group by 取年(时间)select 取年(t1.时间),t2.科目名称,sum(t1.费用)from t1,t2
where 格式(t1.时间)=t2.时间 and t1.科目编号=t2.科目编号 group by 取年(t1.时间);with cte as
(
select 科目编号,科目名称 ,pm=row_number()over(partition by 科目名称 order by getdate())
)
select * from cte where pm=1