ALTER PROCEDURE [dbo].[PHDT_GetQuarterSuccessBorrowTotal]
(
@userName varchar(20)--当前用户
)
AS
BEGIN
declare @Num int,@Quarter int,@Year int;
set @Num=4;
set @Quarter=DatePart(Q,GETDATE());
set @Year=DatePart(YEAR,GETDATE());
create table #tb_quarter(q int,y int);
while(@Num>0)
begin
insert into #tb_quarter(q,y) values(@Quarter,@Year);
set @Quarter=@Quarter-1;
set @Num=@Num-1;
if(@Quarter=0)
begin
set @Quarter=4;
set @Year=@Year-1;
end
end ;
with temp as
(
select confirmTime,borrowMoney from [dbo].[tb_borrowInfo] as b where b.userName=@userName and b.listStatus in('13','14')
)
select tb.q as [Quarter],tb.y as [Year],sum(t.borrowMoney) as Total from #tb_quarter as tb left join temp as t on DatePart(q,t.confirmTime)=tb.q
group by tb.q,tb.y
END
标红的地方是出错的地方.提示失去了语句错误
有些内置函数2012有,但是2008没有的,看看是不是 这个问题。
谢谢你,视图里面的函数我都看了,没有错误的.函数都可以使用.
提示的错误具体是什么?最好错误全部列出来,可能是细节问题