10/09/2011

CASE statement giving error in SSRS query designer

This is someting "back to basics" stuff.. :)

In SSRS query designer I needed write CASE statement like this:

        (CASE WHEN (tf_table.applicationtype = 1)  THEN ('first') 
         ELSE (tf_table.applicationtype) ) AS application

.....But I got error message:

I took off brackets and added "end" to the statement:

        CASE WHEN (tf_table.applicationtype = 1) THEN ('first')
        ELSE (tf_table.applicationtype) END AS application

Case statement was now fixed but then I got execution error:


I still had to correct matching data types. I decided to cast applicationtype to varchar:

        CASE WHEN
        (CAST(tf_table.applicationtype AS varchar(1)) = '1')
        THEN ('first')
        ELSE (CAST(tf_table.applicationtype AS varchar(1)))

        END AS application 

.....And after that I could continue with my report query.

1 comment:

  1. Hey! Have you ever noticed, has your writting technique gone any better recently?

    ReplyDelete