I'm only able to SELECT on a table.
The table has a column called inty with a value of 0 or 1
I am currently selecting inty as:
SELECT inty AS InternetApproved FROM Table1
Is there a way to reformat the data within the SQL SELECT so that if the value is 0 make it No and if the value is 1 make it Yes for display purposes in the output SELECT results?
The syntax for assigning a value to a SQL variable within a SELECT query is @ var_name := value , where var_name is the variable name and value is a value that you're retrieving. The variable may be used in subsequent queries wherever an expression is allowed, such as in a WHERE clause or in an INSERT statement.
There is no difference between EXISTS with SELECT * and SELECT 1. SQL Server generates similar execution plans in both scenarios. EXISTS returns true if the subquery returns one or more records. Even if it returns NULL or 1/0.
Simple and easy way to achieve this is:
SELECT IF(inty = 1, 'YES', 'No') AS internetApproved FROM Table1
SELECT
CASE
WHEN inty = 0 then 'No'
WHEN inty = 1 then 'Yes'
ELSE 'Maybe'
END
AS InternetApproved
FROM Table1
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