Good afternoon,
I always enjoy writing sql, even more when I run into things like this. I am trying to get the count between two dates as well as add aliases to the table which you will see after the "as" statements. I am receiving the error Incorrect syntax near the keyword 'as'.
Here is my code:
SELECT
LoanNum,
RecordNum,
RequestNum,
case
when CloseDt is null
then CAST(SubmitDt - getdate() as int)
as RequestAge
else CAST(SubmitDt - Closedt as int) as RequestAge
end
case
when Followupdt is null
then CAST(SubmitDt - getdate() as int) as AgeFromLastActivity
else CAST(Followupdt - getdate() as int) as AgeFromLastActivity
end
AssigneeName,
Category,
RequestType,
RequestSource,
SubmitDt,
OrderDt,
FollowupDt,
CloseDt,
Disposition
FROM ProdAdmin.dbo.tblAuditSupportRequest
order by LoanNum