Reputation: 131
I am trying to get a boolean i grab in a sql command to send a word instead of 1/0 or true/false.
The code i am using is below, and where it grabs p.premium, i want it to see if it a 0 or a 1. An if its a 1 change the value to "paid" and if its a 0 the change the value to "free".
iv tried case statement but it failed haha.
SELECT P.Id AS Ref
,P.Listed AS Listed
,Convert(Date, Convert(VarChar, P.ListedDate, 12)) AS DateListed
,P.Premium AS Type
,P.PostCode AS London
,Convert(Date, Convert(VarChar,(SELECT TOP 1 MoveInDate FROM PropertyTenant WHERE P.Id = PropertyId ORDER BY Id), 12)) AS MoveInDate
FROM [Database].[dbo].[Property] AS P
Upvotes: 0
Views: 507
Reputation: 85096
If you are using SQL Server 2012 you can use IIF:
IIF ( P.Premium = 1, 'true value!', 'false value!' )
Upvotes: 1