1 Flashcards
(19 cards)
Start of every statemtn
SELECT
Reference a database table
FROM
Produce 10 rows
LIMIT 10
Number of user id (no repeat)
COUNT( DISTINCT user_id)
equal, not equal, less than/equal, great than/equal
= <> != <= =>
Condition statement specific date
WHERE date = ‘2022-01-25’
More condition statements
AND
Alternative condition statement
OR
Instead of writing OR device_id = 2 OR device_id = 3 could write
Device_id IN (2,3)
Return true if value is null
IS NULL
Return a word with second letter r
_r%
Aggregate functions
SUM, MAX, MIN, AVG
Rename column name
AS
Change type
CAST(price AS FLOAT)
Make sure returns to 1dp
/100.0
Make Revenue go from highest to lowest
ORDER BY revenue DESC (or ASC)
Put all product ids together to look at number sold for each
GROUP BY product
When an aggregate function use instead of where clause
HAVING AVG(budget) >0
Call the database a different name
Replicated_datawarehouse.THG.Customer c