SELECT DISTINCT c.CustomerID as [Customer ID], c.CompanyName as [Company Name],
CAST(CASE WHEN o.CustomerID IS NULL THEN 'No' ELSE 'Yes' END as varchar) as [Has Orders]
FROM Customers as c
LEFT JOIN Orders as o ON c.CustomerID=o.CustomerID
The resulting data would look like this:
Customer ID | Company Name | Has Orders |
OCEAN | Océano Atlántico Ltda. | Yes |
OLDWO | Old World Delicatessen | Yes |
OTTIK | Ottilies Käseladen | Yes |
PARIS | Paris spécialités | No |
PERIC | Pericles Comidas clásicas | Yes |
No comments:
Post a Comment