O'Reilly logo

Sams Teach Yourself SQL in 10 Minutes by Ben Forta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

SELECT Clause Ordering

This is probably a good time to review the order in which SELECT statement clauses are to be specified. Table 10.2 lists all the clauses we have learned thus far, in the order they must be used.

Table 10.2. SELECT Clauses and Their Sequence
ClauseDescriptionRequired
SELECTColumns or expressions to be returnedYes
FROMTable to retrieve data fromOnly if selecting from a table
WHERERow-level filteringNo
GROUP BYGroup specificationOnly if calculating aggregates by group
HAVINGGroup-level filteringNo
ORDER BYOutput sort orderNo

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required