π Learn: 1/60 days
ππ»ββοΈ SQL Revision (Basics -> Intermediate)
β’ Comparison operation even works for letters. eg: where month_name > 'J' (This will include January). But NULL operations are not valid like greater than check for the null column.
β’ ILIKE is a logical operator for case insensitive matches.
β’ IS NULL check.
β’ COUNT(column_name) will give NOT NULL and NON UNIQUE values.
β’ COALESCE( .... ) any number of arg returns the first NOT NULL argument.
β’ WHERE doesn't work with aggregate columns that's where the HAVING clause comes in
β’ If-then equivalent is CASE- WHEN-THEN-ELSE[Optional]- END in SQL. βοΈ It can be used inside SELECT, GROUP BY, Inside aggregate functions,
COUNT(CASE WHEN year = 'FR' THEN 1 ELSE NULL END)
β’ Declare Variables in SQL using SET @Variable1 = 'test'
π₯ Questions
β’ Write a query that returns all rows for songs that were on the charts in 2013 and do not contain the letter "a".
Ans: NOT ILIKE '%a%'
β’ How to insert a slice of a table into another table?
Ans: Insert into table (col1, col2 ...) values (select col1, col2... )
β’ Write a query that counts the number of 300lb+ players for each of the following regions: West Coast (CA, OR, WA), Texas, and Other (everywhere else).
Ans: group by case ... end
Next: https://mode.com/sql-tutorial/sql-case/
β’ Comparison operation even works for letters. eg: where month_name > 'J' (This will include January). But NULL operations are not valid like greater than check for the null column.
β’ ILIKE is a logical operator for case insensitive matches.
β’ IS NULL check.
β’ COUNT(column_name) will give NOT NULL and NON UNIQUE values.
β’ COALESCE( .... ) any number of arg returns the first NOT NULL argument.
β’ WHERE doesn't work with aggregate columns that's where the HAVING clause comes in
β’ If-then equivalent is CASE- WHEN-THEN-ELSE[Optional]- END in SQL. βοΈ It can be used inside SELECT, GROUP BY, Inside aggregate functions,
COUNT(CASE WHEN year = 'FR' THEN 1 ELSE NULL END)
β’ Declare Variables in SQL using SET @Variable1 = 'test'
π₯ Questions
β’ Write a query that returns all rows for songs that were on the charts in 2013 and do not contain the letter "a".
Ans: NOT ILIKE '%a%'
β’ How to insert a slice of a table into another table?
Ans: Insert into table (col1, col2 ...) values (select col1, col2... )
β’ Write a query that counts the number of 300lb+ players for each of the following regions: West Coast (CA, OR, WA), Texas, and Other (everywhere else).
Ans: group by case ... end
Next: https://mode.com/sql-tutorial/sql-case/