SELECT Statement, FROM Clause Examples


SQL statement



SELECT [Last Name], [First Name]
FROM Employees

Selects the Last Name and First Name fields of all records in the Employees table.

SELECT Employees.*
FROM Employees

Selects all fields from the Employees table.

SELECT Orders.[Order ID],
[Product ID],[Unit Price]
FROM Orders, [Order Details]

Because the Order ID field appears in both the Orders and Order Details tables, this statement specifies that Order ID be retrieved from the Orders table.  Product ID and Price appear only in the Order Details table, so the name of the table doesn't have to be specified.

SELECT Count("[Postal Code]")
AS Tally
FROM Customer

Counts the number of records that have an entry in the Postal Code field and places the title Tally at the top of the column.

SELECT [Last Name], Salary * 1.1
AS Proposed
FROM Employees

Shows what the salary would be if each employee received a 10 percent raise.  It does not change the original salary amounts.

SELECT [Last Name]
AS Name, Salary
FROM Employees

Places the title Name at the top of the Last Name column.  The title Salary appears at the top of the Salary column.

SELECT Count(*), Avg(Salary), Max(Salary)
FROM Employees

Shows the number of employees and the average and maximum salaries.

SELECT [Last Name], 'has a salary of', Salary
FROM Employees

For each record, shows the Last Name and Salary in the first and last fields.  It displays "has a salary of" in the middle field of each record.