I have a table in SQL database, where one column contains the character "C" or "P". I want to define a new column, where the value is 1, if this character is "C" and zero otherwise.
kind regards, Daniel
if you want to define through projection, try
SELECT columnName, IF(columnName = 'C', 1, 0) newValue
FROM tableName
As an alternative suggested by Michael Berkowski,
SELECT columnName, (columnName = 'C') newValue
FROM tableName
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With