You can not use the case statement like in your code.
If you want to get a different field's value by your condition you can use the case statement like the following examples.
selectid,CASEWHEN condition1 THEN fldx1 ENDAS a1,CASEWHEN condition1 THEN fldx2 ENDAS a2,CASEWHEN condition1 THEN fldx3 ENDAS a3,CASEWHEN condition2 THEN fldy1 ENDAS b1,CASEWHEN condition2 THEN fldy2 ENDAS b2,CASEWHEN condition2 THEN fldy3 ENDAS b3FROM your_table
If you use like above, you have lots of null values.
If you don't have to use column names like a1, a2,a3, b1,b2, or b3 like in your code, I suggest using like the following
selectid,CASEWHEN condition1 THEN fldx1 WHEN condition2 THEN fldy1 ELSE aaa1ENDAS a1,CASEWHEN condition1 THEN fldx2 WHEN condition2 THEN fldy2 ELSE aaa2ENDAS a2,CASEWHEN condition1 THEN fldx3 WHEN condition2 THEN fldy3ELSE aaa3ENDAS a3FROM your_table
Merlin D. Tchouante,Sr. IT Enterprise Application Developer Center for Information Technology Services (CITS) 601 West Lombard Street Baltimore, Maryland 21201-1512 mtchouan@umaryland.edu 410-706-4489 * 410-706-1500 fax