What is a Query

Restriction: This topic applies to Windows environments only.

A query is a question about your data that allows you to retrieve specific information from your database. It is an instruction to the database system to search for a particular set of data that is of interest to you, and to present it in a useful format.

A query is written as an SQL SELECT statement, as in the following example of a fairly complex query that finds the number of customers in each city in New York or California that has at least one customer. The result is sorted by state and city.

SELECT   St, City, Count(C_no)
FROM     Customer
WHERE    St="CA"  OR  City="New York"  
GROUP BY St, City
HAVING   count(*) > 0
ORDER BY St, City

The SELECT statement consists of several important clauses.