Return to Snippet

Revision: 67160
at August 18, 2014 08:23 by lottegis


Updated Code
SELECT   CASE column WHEN 'search_string' THEN 'replace_string1' ELSE 'replace_string2' END AS column_rename
FROM     table


--Example
SELECT   OBJECTID,
         CASE PDF_NAME WHEN '' THEN '' ELSE '<a href="./doc/logbooks/'>' + PDF_NAME + '</a>' END AS LogBooks,
         CASE DAILY_REP WHEN '' THEN '' ELSE '<a href="./doc/Reports/'>' + DAILY_REP + '</a>' END AS DailyReport,
         STR_NAME, Shape
FROM     DatabaseName.TableName

Revision: 67159
at August 18, 2014 08:21 by lottegis


Updated Code
SELECT   CASE column WHEN 'search_string' THEN 'replace_string1' ELSE 'replace_string2' END AS column_rename
FROM     table


'''Example
SELECT   OBJECTID,
         CASE PDF_NAME WHEN '' THEN '' ELSE '<a href="./doc/logbooks/'>' + PDF_NAME + '</a>' END AS LogBooks,
         CASE DAILY_REP WHEN '' THEN '' ELSE '<a href="./doc/Reports/'>' + DAILY_REP + '</a>' END AS DailyReport,
         STR_NAME, Shape
FROM     DatabaseName.TableName

Revision: 67158
at August 18, 2014 08:20 by lottegis


Initial Code
SELECT   CASE column WHEN 'search_string' THEN 'replace_string1' ELSE 'replace_string2' END AS column_rename
FROM     table

Initial URL

                                

Initial Description
Example below

Initial Title
Conditional SQL statement

Initial Tags

                                

Initial Language
SQL