Module 02b - Basic SQL - Part I/II Flashcards
SELECT statement
SELECT [Column]
FROM [Table]
WHERE [condition];
How to eliminate duplicates
SELECT DISTINCT
Which are the the characteristics of WHERE clause
- Case sensitive constants
- Is a optional clause
- Admits conjunction with ‘AND’ and ‘OR’ operators
How to sort results
With the clause ‘ORDER BY’
How to change ascending and descending order
Using ASC ou DESC, as following:
ORDER BY [Column] DESC, [Column] ASC
Which options WHERE clause has?
AND to add more than one condition
OR to admit one condition OR another
IN to look for a condition of a sub-conjunct
NOT IN to negate a condition of sub-conjunct
BETWEEN to establish ranges
Math symbols
LIKE that admits wildcards _ or % (SQL 92)
Which built-in Functions SQL has
COUNT - counts the amount of rows
SUM - sums the values of a column
AVG - returns the average value of a column
MIN - returns the minimum value of a column
MAX - returns the maximum value of a column
Is it possible to make arithmetic calculations between columns?
Yes. By using statements like:
SELECT [Column1] * [Column2] AS Result…
SELECT [Column1] / [Column2] AS Result…
SELECT [Column1] + [Column2] AS Result…
…
How to return String Functions on Oracle SQL
Using concatenation symbols and character strings between simple coma, e.g.:
SELECT [Column1] || ‘ made of ‘ || [Column2]
How to group results from a report?
Using the SQL keyword ‘GROUP BY’
How to state GROUP BY keyword?
WHERE is placed before GROUP BY
How restrict grouped results
Using HAVING operator
How to eliminate a ambiguity when using HAVING operator
By always applying WHERE clause before HAVING operator, just for sure