A comprehensive summary of SQL content at a Grade 11 Level. It contains all the necessary information in a colourful, table format. Diagrams of complex topics have been included. All information has been typed for improved legibility.
SELECT *
FROM <tableName>
ORDER BY <field1> ( ASC / DESC ), … <fieldn> ( ASC / DESC )
ORDER BY Orders selected fields only, in order of the fields entered (field1 before field2)
ASC Ascending
DESC Descending
SELECT TOP <n> * // MS ACCESS will return all rows with that value
FROM <tableName>
ORDER BY <field1> ( ASC / DESC ), … <fieldn> ( ASC / DESC )
TOP <n> ● Limit the number of rows displayed in a table
● TOP 1 can be used to find the largest / smallest, as it limits the result to one record
2
, 3
2. Limiting The Fields
SELECT <field1>, … <fieldn>
FROM <tableName>
<field1>, … <fieldn> Which fields are displayed and in what order
SELECT DISTINCT <field1>, … <fieldn>
FROM <tableName>
DISTINCT Fetch unique rows based on the fields selected, ignoring duplicates
3. Calculations
SELECT <field1>, … <fieldn>, <calculations>
FROM <tableName>
<calculations> The result set will display the listed fields as columns and a new column for
each calculation
The new column is given a random name e.g. ‘Expr1005’
SELECT <field1>, … <fieldn>, <calculations> AS [name]
FROM <tableName>
AS [name] Specifies the name for the column
Use square brackets for 3 words or more, or if the name includes keywords e.g. BY
Can also use CamelCase
3
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through EFT, credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying this summary from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller Zeyni. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy this summary for R125,00. You're not tied to anything after your purchase.