0% found this document useful (0 votes)
5 views4 pages

SQL BOOTCAMP 2022

The document provides an overview of SQL fundamentals, including database concepts, SQL statements, and practical challenges for users to practice SELECT, SELECT DISTINCT, COUNT, and WHERE clauses. It outlines various SQL operations such as ORDER BY and LIMIT, along with specific challenges to reinforce learning through real-world scenarios. Additionally, it lists platforms like PostgreSQL and includes example queries for clarity.

Uploaded by

thenuthamb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views4 pages

SQL BOOTCAMP 2022

The document provides an overview of SQL fundamentals, including database concepts, SQL statements, and practical challenges for users to practice SELECT, SELECT DISTINCT, COUNT, and WHERE clauses. It outlines various SQL operations such as ORDER BY and LIMIT, along with specific challenges to reinforce learning through real-world scenarios. Additionally, it lists platforms like PostgreSQL and includes example queries for clarity.

Uploaded by

thenuthamb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

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;

o EXAMPLE ( AND OPERATION)


SELECT COUNT (*) FROM film
WHERE rental_rate>4 AND replacement_cost>=19.99
AND rating='R';
o EXAMPLE ( OR OPERATION)
SELECT COUNT (*) FROM film
WHERE rating='R'OR rating='PG-13';
o EXAMPLE ( NOT = OPERATION)
SELECT * FROM film
WHERE rating!='R';
- Challenge 3A (SELECT WHERE)
o Situation:
 Track down their email to inform them
 Customer with name Nancy Thomas
o Hint
 Use customer table
o Solutions:
 SELECT email FROM customer WHERE first_name = 'Nancy' AND
last_name='Thomas';
- Challenge 3B (SELECT WHERE)
o Situation:
 Moive “Outlaw Hanky”
 Give descriptions
o Hint
 Use film table
o Solutions:
 SELECT description FROM film WHERE title='Outlaw Hanky';
- Challenge 3C (SELECT WHERE)
o Situation:
 The phone number for the customer who lives at ‘259 Ipoh Drive’
o Hint
 Use address table
o Solutions:
 SELECT phone FROM address WHERE address='259 Ipoh Drive';
- ORDER BY
o To sort rows based on a column value in either ascending or descending order
o SELECT column1,column2 FROM table
ORDER BY column_1 ASC/DESC
- LIMIT
o To limit the number of rows returned for a query
- Challenge 4A (ORDER BY )
o Situation:
 Reward first 10 paying customers
 What are the customer ids of the first 10 customers who created a
payement?
o Hint
 Use payment table
o Solutions:
 SELECT customer_id FROM payment
ORDER BY payment_date ASC
LIMIT 10;
- Challenge 4B (ORDER BY )
o Situation:
 What are the titles of the 5 shortest(in length of runtime)movies
o Hint
 Use film table
o Solutions:
 SELECT title,length FROM film
ORDER BY length ASC
LIMIT 5;
- BETWEEN
o Match a value against a range of values

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy