Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

SQL server query column yes or no

SELECT  a.ID, a.FirstName, a.Lastname,
        CASE WHEN COUNT(b.CustID) > 0 THEN 'YES' ELSE 'NO' END AS HasOrders
FROM    Customer a
        LEFT JOIN Orders b
            ON a.ID = b.CustID        -- <<== the linking column on both tables
GROUP   BY a.ID, a.FirstName, a.Lastname
 
PREVIOUS NEXT
Tagged: #SQL #server #query #column
ADD COMMENT
Topic
Name
6+5 =