sql 语句问题。(access数据库)下面的句子老是提示"至少有一个参数未被指定",请各位大侠指教如何修改...
selectyear(u_time)as年,sum(iif(datepart('q',u_time)=1,1,0))as[第一季度],sum(iif(datepart('...
select year(u_time) as 年, sum(iif(datepart('q',u_time)=1,1,0)) as [第一季度], sum(iif(datepart('q',u_time)=2,1,0)) as [第二季度],sum(iif(datepart('q',u_time)=3,1,0)) as [第三季度], sum(iif(datepart('q',u_time)=4,1,0)) as [第四季度], sum(1) as 全年 from cust_infor group by year(u_time)
展开
1个回答
展开全部
应修改如下:
select 年, sum([第一季度]) as [第一季度合计], sum([第二季度]) as [第二季度合计],sum([第三季度]) as [第三季度合计], sum([第四季度]) as [第四季度合计], sum( 全年) as 全年合计
From
(SELECT year(u_time) as 年,iif(datepart('q',u_time)=1,1,0) as [第一季度], iif(datepart('q',u_time)=2,1,0) as [第二季度],iif(datepart('q',u_time)=3,1,0) as [第三季度], iif(datepart('q',u_time)=4,1,0) as [第四季度], 1 as 全年 from cust_infor)
group by 年;
select 年, sum([第一季度]) as [第一季度合计], sum([第二季度]) as [第二季度合计],sum([第三季度]) as [第三季度合计], sum([第四季度]) as [第四季度合计], sum( 全年) as 全年合计
From
(SELECT year(u_time) as 年,iif(datepart('q',u_time)=1,1,0) as [第一季度], iif(datepart('q',u_time)=2,1,0) as [第二季度],iif(datepart('q',u_time)=3,1,0) as [第三季度], iif(datepart('q',u_time)=4,1,0) as [第四季度], 1 as 全年 from cust_infor)
group by 年;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询