SQL for Data Analysis
SQL for Data Analysis
Analysis
SELECT *
FROM Table
LIMIT 5;
-By Satyam Muley
Get a unique list of cities where there are listings
SELECT DISTINCT city
FROM Table;
SELECT *
FROM Table
WHERE number_of_rooms >= 3;
SELECT *
FROM Table
WHERE number_of_rooms <= 3;
Get all listings where city starts with "j" and where it
does not end with "t"
SELECT *
FROM Table
WHERE city LIKE 'j%' AND city NOT LIKE '%t';
SELECT *
FROM Table
WHERE number_of_rooms IS NOT NULL;
SELECT SUM(number_of_rooms)
FROM Table;
Get the listing with the highest number of rooms across all listings
SELECT MAX(number_of_rooms)
FROM Table;
For Japan and the USA, get the average number of rooms per listing in
each country
SELECT country, AVG(number_of_rooms)
FROM airbnb_listings
WHERE country IN ('USA', 'Japan');
GROUP BY country;