Conditional SQL statement


/ Published in: SQL
Save to your folder(s)

Example below


Copy this code and paste it in your HTML
  1. SELECT CASE COLUMN WHEN 'search_string' THEN 'replace_string1' ELSE 'replace_string2' END AS column_rename
  2. FROM TABLE
  3.  
  4.  
  5. --Example
  6. SELECT OBJECTID,
  7. CASE PDF_NAME WHEN '' THEN '' ELSE '<a href="./doc/logbooks/'>' + PDF_NAME + '</a>' END AS LogBooks,
  8. CASE DAILY_REP WHEN '' THEN '' ELSE '<a href="./doc/Reports/'>' + DAILY_REP + '</a>' END AS DailyReport,
  9. STR_NAME, Shape
  10. FROM DatabaseName.TableName

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.