What am I doing wrong on this one?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • troy howard
    New Member
    • Jan 2011
    • 2

    What am I doing wrong on this one?

    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 AgeFromLastActi vity
    else CAST(Followupdt - getdate() as int) as AgeFromLastActi vity
    end
    AssigneeName,
    Category,
    RequestType,
    RequestSource,
    SubmitDt,
    OrderDt,
    FollowupDt,
    CloseDt,
    Disposition
    FROM ProdAdmin.dbo.t blAuditSupportR equest
    order by LoanNum
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Code:
    (CASE WHEN boolean THEN 'text1' ELSE 'text2' END) AS Field1

    Comment

    Working...