Friday 22 June 2012

1.c) ALL & DISTINCT Keywords in SQL


ALL and DISTINCT are keywords used to select either ALL (default) or the "distinct" or unique records in your query results. If you would like to retrieve just the unique records in specified columns, you can use the "DISTINCT" keyword. DISTINCT will discard the duplicate records for the columns you specified after the "SELECT" statement: 

For example:
 
SELECT DISTINCT age 
 
FROM employee_info;

This statement will return all of the unique ages in the employee_info table.
ALL will display "all" of the specified columns including all of the duplicates. The ALL keyword is the default if nothing is specified.
Note: The following two tables will be used throughout this course. It is recommended to have them open in another window or print them out.

No comments:

Post a Comment