Hello
everyone, today's I am going to share the query for select true and false based on column value using
the SQL CASE as given below.
CASE
WHEN ColumnName
IS NULL THEN 'False' ELSE 'True' END
In
the below example, UNIT is a table name and UNITID, UNIT and UPDATEDATE is the
columns name. Here I using the case on UPDATEDATE column.
For
the detail you can see the example.
SELECT E.UNITID,
E.UNIT,
CASE
WHEN E.UPDATEDDATE IS NULL THEN 'NOT UPDATED'
ELSE 'UPDATED'
END AS RTURNING
FROM
UNIT E
--OR
SELECT
MP.MASTERPLANID,
MP.DISPLAYNAME,
CASE
WHEN
MP.MOBILENO IS NULL THEN 'False'
ELSE
'True'
END AS ADDONS
FROM
MASTERPLAN MP WHERE MP.EQUIPMENTID=8
Please
see the live output as given in below screen.
Thank you!