Test 1 - Module 2 Flashcards
Ad-hoc queries
A non-standard inquiry, created to obtain information as the need arises. Contrast with a query that is predefined and routinely processed
Components of a data warehouse
- Operational databases, other internal data, external data
- ETL System (extraction/cleaning/preparation)
- DW DBMS
- BI tools
SQL
- to work with relational databases
- Starts since 1970
- Not a full programming language
- Data sublanguage
SQL categories
DDL: Data Definition Language
DML: Data Manipulation Language
SELECT statement
SELECT [Column]
FROM [Table]
WHERE [condition];
How to eliminate duplicates
SELECT DISTINCT
WHERE
WHERE … AND…
WHERE … IN …
WHERE … NOT IN …
WHERE … BETWEEN …
How to sort results
With the clause ‘ORDER BY’
ORDER BY [Column] DESC, [Column] ASC
//optional operators
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
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
What is the syntax of a subquery in a DDL statement
SELECT SUM (ExtendedPrice) AS Revenue FROM ORDER_ITEM WHERE SKU IN (SELECT SKU FROM SKU_DATA WHERE Department = 'Water Sports');