https://github.com/poboisvert/docker_sql_csv_loader
[SQL] A Docker image with a SQL UI to practice queries with loaded CSV files
https://github.com/poboisvert/docker_sql_csv_loader
docker postgres queries sql sqlpad
Last synced: about 2 months ago
JSON representation
[SQL] A Docker image with a SQL UI to practice queries with loaded CSV files
- Host: GitHub
- URL: https://github.com/poboisvert/docker_sql_csv_loader
- Owner: poboisvert
- Created: 2022-08-16T16:35:01.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-08-18T02:03:09.000Z (almost 4 years ago)
- Last Synced: 2025-06-20T11:12:39.550Z (about 1 year ago)
- Topics: docker, postgres, queries, sql, sqlpad
- Homepage:
- Size: 115 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### Purpose
- I want to create SQL and have an UI to create/validate queries
- I need to confirm my SQL tables will work with the primary and foreign keys
- I want to load csv into SQL and see if my tables work
### Installation
- CSV files are located: /data
- SQL ORM: /sql
- Install Docker && run "docker-compose up" in the root folder
### SQL Queries
`SELECT * FROM customers`
`SELECT * FROM bookings`
`SELECT * FROM restaurants`
--How many days has each customer visited the restaurant?
`SELECT customer_id, COUNT(DISTINCT(bookings_date)) AS visit_count FROM bookings GROUP BY customer_id;`
-- What was the first restaurant visited by each customer?
```
WITH order_booking AS
(
SELECT
customer_id,
r.name as restaurant_name,
DENSE_RANK() OVER(PARTITION BY customer_id ORDER BY bookings_date) AS rank
FROM bookings AS b
JOIN customers AS c
ON c.id = b.customer_id
JOIN restaurants AS r
ON c.restaurants_id = r.id
)
SELECT
customer_id, restaurant_name
FROM order_booking
WHERE rank = 1
GROUP BY customer_id, restaurant_name;
```