Distinct

The SELECT keyword allows us to grab all information from a column (or columns) on a table. This, of course, necessarily mean that there will be redundancies. What if we only want to select each DISTINCT element? This is easy to accomplish in SQL. All we need to do is to add DISTINCT after SELECT. The syntax is as follows:

Syntax for SQL Distinct

For example, to select all distinct stores in Table Store_Information,

Table Store_Information

store_nameSalesDate
Los Angeles$1500Jan-05-1999
San Diego$250Jan-07-1999
Los Angeles$300Jan-08-1999
Boston$700Jan-08-1999

we key in,

SELECT DISTINCT store_name FROM Store_Information

Result:

store_name
Los Angeles
San Diego
Boston

Next: SQL WHERE