I have a question about using the DISTINCT keyword in SQL. I have a table named Customers. Each record contains 3 fields: CustID, CustName, CustCity. 5 records show a CustCity of "Chicago".
I want the SQL results to show just one record for each unique city name. Also, I just want to see the CustID and the CustName from each record.
I tried this but got a syntax error:
SELECT CustID, CustName DISTINCT CustCity
FROM Customers
DISTINCT
applies to all columns in the select list and must be written before all columns.