Sure, here are some example queries that you can perform on Airbnb data. I'll divide them into CRUD (Create, Read, Update, Delete) and aggregation queries, and provide you with the top 10 queries.
CRUD Queries:
- Create a new listing:
INSERT INTO listings (listing_id, host_id, room_type, price, minimum_nights, availability_365)
VALUES (12345, 67890, 'Entire home/apt', 150, 2, 365);
- Read a listing by ID:
SELECT * FROM listings WHERE listing_id = 12345;
- Update the price of a listing:
UPDATE listings SET price = 200 WHERE listing_id = 12345;
- Delete a listing:
DELETE FROM listings WHERE listing_id = 12345;
- Create a new host:
INSERT INTO hosts (host_id, host_name, host_since, host_location)
VALUES (67890, 'John Doe', '2020-01-01', 'New York');
- Read a host by ID:
SELECT * FROM hosts WHERE host_id = 67890;
- Update the host name:
UPDATE hosts SET host_name = 'Jane Doe' WHERE host_id = 67890;
- Delete a host:
DELETE FROM hosts WHERE host_id = 67890;
Aggregation Queries:
- Find the average price of listings in a particular neighborhood:
SELECT neighborhood, AVG(price) FROM listings GROUP BY neighborhood;
- Find the number of listings hosted by each host:
SELECT host_id, COUNT(*) FROM listings GROUP BY host_id;
- Find the total revenue generated by a host:
SELECT host_id, SUM(price * minimum_nights) FROM listings GROUP BY host_id;
- Find the number of listings available in a particular month:
SELECT EXTRACT(MONTH FROM availability_365) as month, COUNT(*) FROM listings GROUP BY month;
- Find the most common room type:
SELECT room_type, COUNT(*) as count FROM listings GROUP BY room_type ORDER BY count DESC LIMIT 1;
- Find the host with the most listings:
SELECT host_id, COUNT(*) as count FROM listings GROUP BY host_id ORDER BY count DESC LIMIT 1;
- Find the average price of listings for each host:
SELECT host_id, AVG(price) as avg_price FROM listings GROUP BY host_id;
Top 10 Queries:
Here are the top 10 queries from the list above:
- Read a listing by ID.
- Read a host by ID.
- Find the average price of listings in a particular neighborhood.
- Find the number of listings hosted by each host.
- Find the total revenue generated by a host.
- Find the number of listings available in a particular month.
- Find the most common room type.
- Find the host with the most listings.
- Find the average price of listings for each host.
- Update the price of a listing.