Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Thu Jul 09, 2009 7:42 pm Post subject:
subho,
you don't need to code cast and case statement for getting the desired. Since your where clause is already picking a defined set of records , you really don't need the second when statement as the first when is covering the other possible values , so an else is sufficient instead of another when statement
Try this untested sql
Code:
SELECT CASE WHEN A1 IN (1,2,9)
THEN SMALLINT(4) ELSE SMALLINT(5)
END
,COL2
FROM TABLE1
WHERE A1 IN (1,2,6,7,9)
;
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum