Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB SQL » View Thread |
Messages 1 to 3 of 3 total |
Naming of Column using CASE in SELECT statement |
Wed, Aug 19 2015 6:03 AM | Permanent Link |
James Dooley | Hello,
I've got the following select statement in which the name of the column using the CASE statement appears as 'CASE': SELECT record_id AS Id, CASE action WHEN 'I' THEN 'Inserted' WHEN 'U' THEN 'Updated' ELSE 'Deleted' END CASE, key AS Parameter, value AS Value, actioned_by AS User FROM parameter_xxx And I would like to the column named 'ActionType', but if I and an AS ActionType after the CASE statement I get an error message complaining about the AS... So what is the secret to doing this??? Thanks. |
Wed, Aug 19 2015 7:24 AM | Permanent Link |
Adam Brett Orixa Systems | Hi James,
Here is an example: SELECT ID, CASE WHEN Action = 'I' THEN 'Inserted' WHEN Action = 'U' THEN 'Updated' ELSE 'Deleted' END as ActionType ... Note that the Boolean expression (Action = xxxx in this example) after WHEN must evaluate to true for the THEN to be triggered. After the "END" you can name the column |
Wed, Aug 19 2015 1:38 PM | Permanent Link |
James Dooley | Thanks!
|
This web page was last updated on Monday, April 29, 2024 at 05:23 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |