0

I would like to write a SQL query with a condition inside of it.

I got one table with two columns named "i" and "i_o".

What I want is to use the values of "i" for labeling my entities BUT if the value of "i" is "other" then it would show the value of "i_o" instead of "i" for the same row.

I'm a noob in SQL so I don't really know of to get that working.

1
  • 1
    Can you please provide the code you have so far?
    – Mapperz
    Commented Oct 15, 2021 at 13:28

1 Answer 1

1

A solution using a case

SELECT CASE
  WHEN i = 'other' THEN i_o
  ELSE i
END as i
FROM your_table

You can mostly do the same without any SQL using QGIS expressions for labeling if using Desktop GIS like QGIS but I do not know your usage context (web or desktop, software used,...)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.