Lists selected data from the database.
SELECT [ALL] [DISTINCT] values FROM SQLsetspec [-> setname]
|ALL||An optional keyword indicating that all records of the specified type are to be listed. But, even if ALL is omitted, all records are processed by default.|
|DISTINCT||Specifies that only the records that contain unique values in the fields being displayed are to be listed.|
An asterisk indicates that all fields in the listed records are to be displayed.
One or more expressions whose values are to be displayed for each listed record. Each expression must be separated from the next by a comma.
|SQLsetspec||An SQL set specification.|
The SELECT command is the SQL equivalent of the LIST command.
You can include sub-queries using the SELECT command in SQLsetspec.
select LastName,FirstName from Employees,Departments
where Employees.DNo = Departments.DNo
list Employees WorkIn Departments format LastName FirstName
The preceding two commands produce equivalent results.
select $max(Salary) from Employees group by DNo
having $average(Salary) > 30000
In the preceding command, the keywords GROUP BY and HAVING produce a list of the highest-salaried employees within each department number where the average salary is greater than $30,000.
select * from Emps order by LastName
The preceding command lists all the fields in each employee record. The records are listed in alphabetical order by last name.
select distinct LastName,FirstName from Emps
The preceding command lists the first and last names of all employees, eliminating duplicates where two or more employees have exactly the same first and last name.