1SELECT a.ID, a.FirstName, a.Lastname,
2 CASE WHEN COUNT(b.CustID) > 0 THEN 'YES' ELSE 'NO' END AS HasOrders
3FROM Customer a
4 LEFT JOIN Orders b
5 ON a.ID = b.CustID -- <<== the linking column on both tables
6GROUP BY a.ID, a.FirstName, a.Lastname