SQL BOOTCAMP 2022
SQL BOOTCAMP 2022
What is Database?
- Allows users to store and organize data
- Useful when dealing with large amounts of data
- Users
o Analysts
o Technical
PLATFORM Options
- PostgreSQL
- Password: password
SQL STATEMENT FUNDAMENTALS
- SELECT
o Common statement used and allowed to retrieve information from a table
o SELECT column_name FROM table_name;
o EXAMPLE
SELECT c1 FROM table_1 (to select one column
SELECT c1,c2,c3 FROM table_1( to select all the columns)
SELECT * FROM table_1 ( to select all the columns)
In general * “only if you want all columns”
- Challenge 1(SELECT)
o Situation:
Send out a promotional email to our existing customers!
o Challenge
SELECT statement
Grab first and last name of every customer and their email address
o Hints
Use customer table
o Solutions :
SELECT first_name, last_name,email FROM customer;
- SELECT DISTINCT
o Only want to list the unique/distinct values
o Can be used to return only the distinct values in a column
o SELECT DISTINCT column FROM table ;
- Challenge 2 (SELECT DISTINCT)
o Situation:
MPAA movie rating (PG,PG-13,R,ect…)
We want to know the types of ratings we have in our database
What rating do we have available?
o Challenge
Use SELECT DISTINCT
o Hint
Use film table
o Solutions:
SELECT DISTINCT rating From film ;
- COUNT
o Returns the number of input rows that match a specific condition of a query
o SELECT COUNT(name) FROM table;
o SELECT COUNT(choice) FROM table;
o SELECT COUNT(*) FROM table;
o SELECT COUNT(DISTINCT amount) FROM table;
how many unique amount are there
- SELECT WHERE
o WHERE : Specify conditions on columns for the rows to be returned
o SELECT column1,column2 FROM table
WHERE conditions;