feat: tracking databases
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- README.md +7 -0
- test_database/aan_1/aan_1.sqlite +3 -0
- test_database/aan_1/annotation.json +3 -0
- test_database/aan_1/schema.sql +3 -0
- test_database/address_1/address_1.sqlite +3 -0
- test_database/address_1/link.txt +1 -0
- test_database/address_1/schema.sql +3 -0
- test_database/advertising_agencies/advertising_agencies.sqlite +3 -0
- test_database/advertising_agencies/schema.sql +3 -0
- test_database/art_1/art_1.sqlite +3 -0
- test_database/art_1/link.txt +1 -0
- test_database/art_1/q.txt +9 -0
- test_database/bakery_1/annotation.json +3 -0
- test_database/bakery_1/bakery_1.json +3 -0
- test_database/bakery_1/bakery_1.sql +3 -0
- test_database/bakery_1/bakery_1.sqlite +3 -0
- test_database/bakery_1/bakery_1_michi.txt +411 -0
- test_database/bakery_1/data_csv/README.BAKERY.TXT +110 -0
- test_database/bakery_1/data_csv/customers.csv +3 -0
- test_database/bakery_1/data_csv/customers_t.csv +3 -0
- test_database/bakery_1/data_csv/goods.csv +3 -0
- test_database/bakery_1/data_csv/goods_t.csv +3 -0
- test_database/bakery_1/data_csv/items (3:11:18, 5:53 PM)_original.csv +3 -0
- test_database/bakery_1/data_csv/items.csv +3 -0
- test_database/bakery_1/data_csv/items_t.csv +3 -0
- test_database/bakery_1/data_csv/receipts (3:11:18, 5:53 PM)_original.csv +3 -0
- test_database/bakery_1/data_csv/receipts.csv +3 -0
- test_database/bakery_1/data_csv/receipts_t.csv +3 -0
- test_database/bakery_1/link.txt +1 -0
- test_database/bakery_1/q.txt +25 -0
- test_database/bbc_channels/bbc_channels.sqlite +3 -0
- test_database/bbc_channels/schema.sql +3 -0
- test_database/bike_racing/bike_racing.sqlite +3 -0
- test_database/bike_racing/schema.sql +3 -0
- test_database/bike_racing/schema_old.sql +3 -0
- test_database/boat_1/Boats.csv +3 -0
- test_database/boat_1/Reserves.csv +3 -0
- test_database/boat_1/Sailors.csv +3 -0
- test_database/boat_1/boat_1.sqlite +3 -0
- test_database/boat_1/schema.sql +3 -0
- test_database/book_1/annotation.json +3 -0
- test_database/book_1/book_1.sqlite +3 -0
- test_database/book_1/link.txt +1 -0
- test_database/book_1/q.txt +37 -0
- test_database/book_1/schema.sql +3 -0
- test_database/book_1/schema_old.sql +3 -0
- test_database/book_1/sql.txt +97 -0
- test_database/book_press/book_press.sqlite +3 -0
- test_database/book_press/schema.sql +3 -0
- test_database/book_review/book_review.sqlite +3 -0
README.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
---
|
| 4 |
+
|
| 5 |
+
Link to original dataset: https://yale-lily.github.io/spider
|
| 6 |
+
|
| 7 |
+
Yu, T., Zhang, R., Yang, K., Yasunaga, M., Wang, D., Li, Z., Ma, J., Li, I., Yao, Q., Roman, S. and Zhang, Z., 2018. Spider: A large-scale human-labeled dataset for complex and cross-domain semantic parsing and text-to-sql task. arXiv preprint arXiv:1809.08887.
|
test_database/aan_1/aan_1.sqlite
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:54c45e431f0f654bfac741cf69e66ca34dacf42a0d0abbde6fd426a7a1e60c4b
|
| 3 |
+
size 17154048
|
test_database/aan_1/annotation.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2ce4b0210d43f0d7552879fc6fd6ef5bae0ca4e1005d2c36ca162b7ae3581060
|
| 3 |
+
size 65
|
test_database/aan_1/schema.sql
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e2a591352bcdd42bc4fd6a66ed112103c7198d5376c15fffa1861716cf7d4b36
|
| 3 |
+
size 8143522
|
test_database/address_1/address_1.sqlite
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5445559b7dfd1779cefb0198047cfb1de380a394e90ea33d1bc6c4d3a94e12f7
|
| 3 |
+
size 20480
|
test_database/address_1/link.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
http://www.cs.jhu.edu/~yarowsky/jhu.sql
|
test_database/address_1/schema.sql
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:909d6a0114f2f4c5b65c3483b2f2e449f77a64e83433d92f557219f490fa8f2d
|
| 3 |
+
size 13417
|
test_database/advertising_agencies/advertising_agencies.sqlite
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4f7fd1fd606b3bb1f4a988f8557e9dc393e3fc1f9bf097bb79cff07df5d680b7
|
| 3 |
+
size 32768
|
test_database/advertising_agencies/schema.sql
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b7336fdf004bea9235e630fd0c6d727650238f999f370a71c2fe4eefa4a074cd
|
| 3 |
+
size 14517
|
test_database/art_1/art_1.sqlite
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ccfd00de54bbe9a7ce57f226e9634e8c4693520299795fb8da834017fc55d735
|
| 3 |
+
size 8192
|
test_database/art_1/link.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
https://www.classes.cs.uchicago.edu/archive/2015/spring/23500-1/hw3.html
|
test_database/art_1/q.txt
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
q0. Retrieve the title of each painting, the artist's last name, its height in inches and its width in inches in descending order of surface area.
|
| 2 |
+
|
| 3 |
+
q1. Retrieve the artistID, first name, last name, and age at death of the artist(s) who was/were youngest at the time of death. (Note that since the birth and death dates are given as years only, any age computation is approximate, accurate plus or minus one.)
|
| 4 |
+
|
| 5 |
+
q2. Retrieve the titles of all paintings and sculptures, with the artists' last names, in the database and the age the artist was at the time the work was produced, in order of youngest to oldest such age.
|
| 6 |
+
|
| 7 |
+
q3. Retrieve the artist's last name and the title of all the undisplayed works.
|
| 8 |
+
|
| 9 |
+
q4. Write a query to display the artistID, last name and all (distinct) media used by all artists in all paintings. Order the query result by last name, ascending. Your results should include not just the medium ("oil") but the surface the medium is on ("oil on canvas"). Use GROUP_CONCAT to denormalize the data and produce comma-delimited results like this:
|
test_database/bakery_1/annotation.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f13f512f7f1ed20e20e5df75439c866cc18aed69f87db2fe07d6878fcdfda7b1
|
| 3 |
+
size 2373
|
test_database/bakery_1/bakery_1.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f29e25797bdd3ad9e95aee4fa9e0eef1d2d88031d3310732c655f44e430259ae
|
| 3 |
+
size 3682
|
test_database/bakery_1/bakery_1.sql
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7456ce1c3625a368f463efe86524013074c75bc21522ae90c0f8ee95ddd72da8
|
| 3 |
+
size 560
|
test_database/bakery_1/bakery_1.sqlite
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8ab55eb34c0ea8cbe29f9651ec3deae620ba8558e03b0e7740daa871e4eba025
|
| 3 |
+
size 57344
|
test_database/bakery_1/bakery_1_michi.txt
ADDED
|
@@ -0,0 +1,411 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Total # = 51
|
| 2 |
+
|
| 3 |
+
1. What is the most expensive cake and its flavor?
|
| 4 |
+
|
| 5 |
+
select id, flavor
|
| 6 |
+
from goods
|
| 7 |
+
where food = "Cake"
|
| 8 |
+
order by price desc
|
| 9 |
+
limit 1
|
| 10 |
+
|
| 11 |
+
What is the cheapest cookie and its flavor?
|
| 12 |
+
|
| 13 |
+
select id, flavor
|
| 14 |
+
from goods
|
| 15 |
+
where food = "Cookie"
|
| 16 |
+
order by price
|
| 17 |
+
limit 1
|
| 18 |
+
|
| 19 |
+
2. Find the ids of goods that have apple flavor.
|
| 20 |
+
|
| 21 |
+
Select id
|
| 22 |
+
From goods
|
| 23 |
+
Where flavor = "Apple"
|
| 24 |
+
|
| 25 |
+
What are the ids of goods that cost less than 3 dollars?
|
| 26 |
+
|
| 27 |
+
Select id
|
| 28 |
+
From goods
|
| 29 |
+
Where price < 3
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
3. List the distinct ids of all customers who bought a lemon cake?
|
| 33 |
+
|
| 34 |
+
Select DISTINCT T3.CustomerId
|
| 35 |
+
From goods as T1 JOIN items as T2 JOIN receipts as T3 ON T1.Id = T2.Item and T2.Receipt = T3.ReceiptNumber
|
| 36 |
+
Where T1.Flavor = "Lemon" and T1.Food = "Cake"
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
For each type of food, tell me how many customers have ever bought it.
|
| 40 |
+
|
| 41 |
+
Select T1.food, count(distinct T3.CustomerId)
|
| 42 |
+
From goods as T1 JOIN items as T2 JOIN receipts as T3 ON T1.Id = T2.Item and T2.Receipt = T3.ReceiptNumber
|
| 43 |
+
Group by T1.food
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
4. Find the id of customers who shopped at the bakery at least 15 times.
|
| 47 |
+
|
| 48 |
+
Select CustomerId
|
| 49 |
+
From receipts
|
| 50 |
+
Group by CustomerId
|
| 51 |
+
having count(*) >= 15
|
| 52 |
+
|
| 53 |
+
What is the last name of the customers who shopped at the bakery more than 10 times?
|
| 54 |
+
|
| 55 |
+
Select T2.LastName
|
| 56 |
+
From receipts as T1 JOIN customers as T2 ON T1.CustomerId = T2.id
|
| 57 |
+
Group by T2.id
|
| 58 |
+
having count(*) > 10
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
5. How many types of Cake does this bakery sell?
|
| 62 |
+
|
| 63 |
+
Select count(*)
|
| 64 |
+
From goods
|
| 65 |
+
where food = "Cake"
|
| 66 |
+
|
| 67 |
+
List all the flavors of Croissant available in this bakery.
|
| 68 |
+
|
| 69 |
+
Select flavor
|
| 70 |
+
From goods
|
| 71 |
+
where food = "Croissant"
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
6. Give me a list of all the distinct items bought by the customer number 15.
|
| 75 |
+
|
| 76 |
+
Select distinct T1.item
|
| 77 |
+
from items as T1 JOIN receipts as T2 ON T1.receipt = T2.ReceiptNumber
|
| 78 |
+
Where T2.CustomerId = 15
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
For each type of food, what are the average, maximum and minimum price?
|
| 82 |
+
|
| 83 |
+
Select food, avg(price), max(price), min(price)
|
| 84 |
+
from goods
|
| 85 |
+
Group by food
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
7. Find the receipt numbers where both Cake and Cookie were bought.
|
| 89 |
+
|
| 90 |
+
Select T1.receipt
|
| 91 |
+
From items as T1 JOIN goods as T2 ON T1.item = T2.id
|
| 92 |
+
Where T2.food = "Cake"
|
| 93 |
+
INTERSECT
|
| 94 |
+
Select T1.receipt
|
| 95 |
+
From items as T1 JOIN goods as T2 ON T1.item = T2.id
|
| 96 |
+
Where T2.food = "Cookie"
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
Find all the receipt numbers in which customer id 5 purchased Croissant.
|
| 100 |
+
|
| 101 |
+
Select ReceiptNumber
|
| 102 |
+
From receipts
|
| 103 |
+
Where CustomerId = 5
|
| 104 |
+
INTERSECT
|
| 105 |
+
Select T1.receipt
|
| 106 |
+
From items as T1 JOIN goods as T2 ON T1.item = T2.id
|
| 107 |
+
Where T2.food = "Croissant"
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
8. What is the receipt number and date of the receipt in which the most expensive item was bought?
|
| 111 |
+
|
| 112 |
+
Select T1.ReceiptNumber, T1.Date
|
| 113 |
+
From receipts as T1 JOIN items as T2 JOIN goods as T3 ON T1.ReceiptNumber = T2.receipt and T2.item = T3.id
|
| 114 |
+
Order by T3.price Desc
|
| 115 |
+
LIMIT 1
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
What is the item that was bought the least number of times?
|
| 119 |
+
Select item
|
| 120 |
+
From items
|
| 121 |
+
Group by item
|
| 122 |
+
Order by count(*)
|
| 123 |
+
LIMIT 1
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
9. How many goods are available for each food type?
|
| 127 |
+
|
| 128 |
+
Select count(*), food
|
| 129 |
+
From goods
|
| 130 |
+
group by food
|
| 131 |
+
|
| 132 |
+
What is the average price for each food type?
|
| 133 |
+
|
| 134 |
+
Select avg(price), food
|
| 135 |
+
From goods
|
| 136 |
+
group by food
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
10. What are the goods that have Apricot flavor and are cheaper than 5 dollars?
|
| 140 |
+
|
| 141 |
+
Select id
|
| 142 |
+
From goods
|
| 143 |
+
where flavor = "Apricot" and price < 5
|
| 144 |
+
|
| 145 |
+
Find flavor of cakes that cost more than 10 dollars.
|
| 146 |
+
|
| 147 |
+
Select flavor
|
| 148 |
+
From goods
|
| 149 |
+
where food = "Cake" and price > 10
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
11. Give me the distinct id and price for all goods whose price is below the average of all goods?
|
| 153 |
+
|
| 154 |
+
Select distinct id, price
|
| 155 |
+
From goods
|
| 156 |
+
where price < (Select avg(price) From goods)
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
What are the distinct ids of all goods that are cheaper than some goods of type Tart?
|
| 160 |
+
|
| 161 |
+
Select distinct T1.id
|
| 162 |
+
From goods as T1, goods as T2
|
| 163 |
+
where T1.price < T2.price and T2.food = "Tart"
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
12. List distinct receipt numbers for which someone bought a good that costs more than 13 dollars.
|
| 167 |
+
|
| 168 |
+
Select distinct T1.ReceiptNumber
|
| 169 |
+
from receipts as T1 JOIN items as T2 JOIN goods as T3 ON T1.ReceiptNumber = T2.receipt and T2.item = T3.id
|
| 170 |
+
Where T3.price > 13
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
On which date did some customer buy a good that costs more than 15 dollars?
|
| 174 |
+
|
| 175 |
+
Select distinct T1.date
|
| 176 |
+
from receipts as T1 JOIN items as T2 JOIN goods as T3 ON T1.ReceiptNumber = T2.receipt and T2.item = T3.id
|
| 177 |
+
Where T3.price > 15
|
| 178 |
+
|
| 179 |
+
|
| 180 |
+
13. Give me the list of all goods whose id has "APP".
|
| 181 |
+
|
| 182 |
+
Select id
|
| 183 |
+
from goods
|
| 184 |
+
Where id LIKE "%APP%"
|
| 185 |
+
|
| 186 |
+
Which good has "70" in its id? And what is its price?
|
| 187 |
+
|
| 188 |
+
Select id, price
|
| 189 |
+
from goods
|
| 190 |
+
Where id LIKE "%70%"
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
14. List the last names of all customers in an alphabetical oder.
|
| 194 |
+
|
| 195 |
+
Select distinct LastName
|
| 196 |
+
From customers
|
| 197 |
+
Order by LastName
|
| 198 |
+
|
| 199 |
+
Return the ordered list of all good ids.
|
| 200 |
+
|
| 201 |
+
Select distinct id
|
| 202 |
+
From goods
|
| 203 |
+
Order by id
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
15. Find all receipts in which either apple flavor pie was bought or customer id 12 shopped.
|
| 207 |
+
|
| 208 |
+
Select T1.receipt
|
| 209 |
+
From items as T1 JOIN goods as T2 ON T1.item = T2.id
|
| 210 |
+
where T2.flavor = "Apple" and T2.food = "Pie"
|
| 211 |
+
UNION
|
| 212 |
+
Select ReceiptNumber
|
| 213 |
+
From receipts
|
| 214 |
+
where CustomerId = 12
|
| 215 |
+
|
| 216 |
+
|
| 217 |
+
Find all receipts which has the latest date. Also tell me that date.
|
| 218 |
+
|
| 219 |
+
Select ReceiptNumber, date
|
| 220 |
+
From receipts
|
| 221 |
+
where date = (Select date From receipts Order by date Desc LIMIT 1)
|
| 222 |
+
|
| 223 |
+
|
| 224 |
+
Find all receipts which either has the earliest date or has a good with price above 10.
|
| 225 |
+
|
| 226 |
+
Select T1.Receipt
|
| 227 |
+
From items as T1 JOIN goods as T2 ON T1.item = T2.id
|
| 228 |
+
where T2.price > 10
|
| 229 |
+
UNION
|
| 230 |
+
Select ReceiptNumber
|
| 231 |
+
From receipts
|
| 232 |
+
where date = (Select date From receipts Order by date LIMIT 1)
|
| 233 |
+
|
| 234 |
+
|
| 235 |
+
16. What are the ids of Cookie and Cake that cost between 3 and 7 dollars.
|
| 236 |
+
|
| 237 |
+
Select id
|
| 238 |
+
From goods
|
| 239 |
+
where (food = "Cookie" or food = "Cake") and price between 3 and 7
|
| 240 |
+
|
| 241 |
+
|
| 242 |
+
Find the first name and last name of a customer who visited on the earliest date.
|
| 243 |
+
|
| 244 |
+
Select T1.FirstName, T1.LastName
|
| 245 |
+
From customers as T1 JOIN receipts as T2 ON T1.id = T2.CustomerId
|
| 246 |
+
Order by T2.date
|
| 247 |
+
LIMIT 1
|
| 248 |
+
|
| 249 |
+
|
| 250 |
+
|
| 251 |
+
17. What is average price of goods whose flavor is blackberry or blueberry?
|
| 252 |
+
|
| 253 |
+
Select avg(price)
|
| 254 |
+
From goods
|
| 255 |
+
where flavor = "Blackberry" or flavor = "Blueberry"
|
| 256 |
+
|
| 257 |
+
|
| 258 |
+
Return the cheapest price for goods with cheese flavor.
|
| 259 |
+
|
| 260 |
+
Select min(price)
|
| 261 |
+
From goods
|
| 262 |
+
where flavor = "Cheese"
|
| 263 |
+
|
| 264 |
+
|
| 265 |
+
18. What are highest, lowest, and average prices of goods, grouped and ordered by flavor?
|
| 266 |
+
|
| 267 |
+
Select max(price), min(price), avg(price), flavor
|
| 268 |
+
From goods
|
| 269 |
+
group by flavor
|
| 270 |
+
order by flavor
|
| 271 |
+
|
| 272 |
+
|
| 273 |
+
Return the lowest and highest prices of goods grouped and ordered by food type.
|
| 274 |
+
|
| 275 |
+
Select min(price), max(price), food
|
| 276 |
+
From goods
|
| 277 |
+
group by food
|
| 278 |
+
order by food
|
| 279 |
+
|
| 280 |
+
|
| 281 |
+
19. Find the top three dates when the most goods were sold.
|
| 282 |
+
|
| 283 |
+
Select date
|
| 284 |
+
From receipts
|
| 285 |
+
Group by date
|
| 286 |
+
Order by count(*)
|
| 287 |
+
LIMIT 3
|
| 288 |
+
|
| 289 |
+
Which customer shopped most often? How many times?
|
| 290 |
+
|
| 291 |
+
Select CustomerId, count(*)
|
| 292 |
+
From receipts
|
| 293 |
+
Group by CustomerId
|
| 294 |
+
Order by count(*)
|
| 295 |
+
LIMIT 1
|
| 296 |
+
|
| 297 |
+
|
| 298 |
+
20. For each date, return how many distinct customers visited on that day.
|
| 299 |
+
|
| 300 |
+
Select date, count (distinct CustomerId)
|
| 301 |
+
from receipts
|
| 302 |
+
Group by date
|
| 303 |
+
|
| 304 |
+
|
| 305 |
+
Give me the first name and last name of customers who have bought apple flavor Tart.
|
| 306 |
+
|
| 307 |
+
Select distinct T4.FirstName, T4.LastName
|
| 308 |
+
from goods as T1 JOIN items as T2 JOIN receipts as T3 JOIN customers as T4 ON T1.id = T2.item and T2.receipt = T3.ReceiptNumber and T3.CustomerId = T4.id
|
| 309 |
+
where T1.flavor = "Apple" and T1.food = "Tart"
|
| 310 |
+
|
| 311 |
+
|
| 312 |
+
21. What are the ids of Cookies whose price is lower than any Croissant?
|
| 313 |
+
|
| 314 |
+
Select id
|
| 315 |
+
From goods
|
| 316 |
+
where food = "Cookie" and price < (select min(price)
|
| 317 |
+
from goods
|
| 318 |
+
where food = 'Croissant')
|
| 319 |
+
|
| 320 |
+
|
| 321 |
+
Give me the ids of Cakes whose price is at least three times as much as the average price of Tart?
|
| 322 |
+
|
| 323 |
+
Select id
|
| 324 |
+
From goods
|
| 325 |
+
where food = "Cake" and price >= 3 * (select avg(price)
|
| 326 |
+
from goods
|
| 327 |
+
where food = "Tart")
|
| 328 |
+
|
| 329 |
+
|
| 330 |
+
What are the ids of goods whose price is above twice the average price of all goods?
|
| 331 |
+
|
| 332 |
+
Select id
|
| 333 |
+
From goods
|
| 334 |
+
where price > 2 * (select avg(price)
|
| 335 |
+
from goods)
|
| 336 |
+
|
| 337 |
+
|
| 338 |
+
22. List the id, flavor and type of food of goods ordered by price.
|
| 339 |
+
|
| 340 |
+
Select id, flavor, food
|
| 341 |
+
From goods
|
| 342 |
+
order by price
|
| 343 |
+
|
| 344 |
+
|
| 345 |
+
Return a list of the id and flavor for Cakes ordered by flavor.
|
| 346 |
+
|
| 347 |
+
Select id, flavor
|
| 348 |
+
From goods
|
| 349 |
+
where food = "Cake"
|
| 350 |
+
order by flavor
|
| 351 |
+
|
| 352 |
+
|
| 353 |
+
|
| 354 |
+
23. Find all the items that have chocolate flavor but were not bought more than 10 times.
|
| 355 |
+
|
| 356 |
+
Select distinct T1.item
|
| 357 |
+
From items as T1 JOIN goods as T2 ON T1.item = T2.id
|
| 358 |
+
Where T2.flavor = "Chocolate"
|
| 359 |
+
EXCEPT
|
| 360 |
+
Select distinct item
|
| 361 |
+
From items
|
| 362 |
+
Group by item
|
| 363 |
+
having count(*) > 10
|
| 364 |
+
|
| 365 |
+
|
| 366 |
+
What are the flavors available for Cake but not for Tart?
|
| 367 |
+
|
| 368 |
+
Select distinct flavor
|
| 369 |
+
From goods
|
| 370 |
+
where food = "Cake"
|
| 371 |
+
EXCEPT
|
| 372 |
+
Select distinct flavor
|
| 373 |
+
From goods
|
| 374 |
+
where food = "Tart"
|
| 375 |
+
|
| 376 |
+
|
| 377 |
+
24. What is the three most popular goods in this bakery?
|
| 378 |
+
|
| 379 |
+
Select item
|
| 380 |
+
From items
|
| 381 |
+
Group by item
|
| 382 |
+
Order by count (*) DESC
|
| 383 |
+
LIMIT 3
|
| 384 |
+
|
| 385 |
+
|
| 386 |
+
|
| 387 |
+
25. Find the ids of customers who have spent more than 150 dollars in total.
|
| 388 |
+
|
| 389 |
+
Select T3.CustomerId
|
| 390 |
+
From goods as T1 JOIN items as T2 JOIN receipts as T3 ON T1.id = T2.item and T2.receipt = T3.ReceiptNumber
|
| 391 |
+
Group by T3.CustomerId
|
| 392 |
+
having sum(T1.price) > 150
|
| 393 |
+
|
| 394 |
+
|
| 395 |
+
Find the ids of customers whose average spending for each good is above 5.
|
| 396 |
+
|
| 397 |
+
Select T3.CustomerId
|
| 398 |
+
From goods as T1 JOIN items as T2 JOIN receipts as T3 ON T1.id = T2.item and T2.receipt = T3.ReceiptNumber
|
| 399 |
+
Group by T3.CustomerId
|
| 400 |
+
having avg(T1.price) > 5
|
| 401 |
+
|
| 402 |
+
|
| 403 |
+
|
| 404 |
+
On which day did the bakery sell more than 100 dollars in total.
|
| 405 |
+
|
| 406 |
+
Select T3.date
|
| 407 |
+
From goods as T1 JOIN items as T2 JOIN receipts as T3 ON T1.id = T2.item and T2.receipt = T3.ReceiptNumber
|
| 408 |
+
Group by T3.date
|
| 409 |
+
having sum(T1.price) > 100
|
| 410 |
+
|
| 411 |
+
|
test_database/bakery_1/data_csv/README.BAKERY.TXT
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*****************************************************
|
| 2 |
+
CPE 365 Alex Dekhtyar
|
| 3 |
+
Cal Poly Computer Science Department
|
| 4 |
+
San Luis Obispo College of Engineering
|
| 5 |
+
California dekhtyar@csc.calpoly.edu
|
| 6 |
+
*****************************************************
|
| 7 |
+
BAKERY DATASET
|
| 8 |
+
Version 1.0
|
| 9 |
+
October 1, 2007
|
| 10 |
+
*****************************************************
|
| 11 |
+
Sources: this is a synthesized dataset.
|
| 12 |
+
|
| 13 |
+
******************************************************
|
| 14 |
+
|
| 15 |
+
This file describes the contents of the BAKERY dataset
|
| 16 |
+
developed for the CPE 365, Introduction to Databases,
|
| 17 |
+
course at Cal Poly.
|
| 18 |
+
|
| 19 |
+
The dataset contains information about one month worth
|
| 20 |
+
of sales information for a small bakery shop. The sales
|
| 21 |
+
are made to known customers. The dataset contains
|
| 22 |
+
information about the customers, the assortments of
|
| 23 |
+
baked goods offered for sale and the purchases made.
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
General Conventions.
|
| 27 |
+
|
| 28 |
+
1. All files in the dataset are CSV (comma-separated values) files.
|
| 29 |
+
2. First line of each file provides the names of
|
| 30 |
+
columns. Second line may be empty, or may contain
|
| 31 |
+
the first row of the data.
|
| 32 |
+
3. All string values are enclosed in single quotes (')
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
The dataset consists of the following files:
|
| 36 |
+
|
| 37 |
+
- customers.csv : information about the bakery's customers
|
| 38 |
+
- goods.csv : information about the baked goods offered
|
| 39 |
+
for sale by the bakery
|
| 40 |
+
- items.csv : itemized reciept infromation for purchases
|
| 41 |
+
- reciepts.csv : general reciept information for purchases
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
reciepts.csv stores information about individual reciepts
|
| 45 |
+
(purchases by customers). Each purchase may contain from
|
| 46 |
+
one two five items, regardless of whether any items
|
| 47 |
+
purchased are of the same kind (e.g., two "chocolate cakes"
|
| 48 |
+
will be billed as two separate items on the reciept).
|
| 49 |
+
items.csv contains itemized reciept information.
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
Individual files have the following formats.
|
| 53 |
+
|
| 54 |
+
**************************************************************************
|
| 55 |
+
|
| 56 |
+
customers.csv
|
| 57 |
+
|
| 58 |
+
Id: unique identifier of the customer
|
| 59 |
+
LastName: last name of the customer
|
| 60 |
+
FirstName: first name of the customer
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
**************************************************************************
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
goods.csv
|
| 68 |
+
|
| 69 |
+
Id : unique identifier of the baked good
|
| 70 |
+
Flavor: flavor/type of the good (e.g., "chocolate", "lemon")
|
| 71 |
+
Food: category of the good (e.g., "cake", "tart")
|
| 72 |
+
Price: price (in dollars)
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
**************************************************************************
|
| 77 |
+
|
| 78 |
+
items.csv
|
| 79 |
+
|
| 80 |
+
Reciept : reciept number (see reciepts.RecieptNumber)
|
| 81 |
+
Ordinal : position of the purchased item on the
|
| 82 |
+
reciepts. (i.e., first purchased item,
|
| 83 |
+
second purchased item, etc...)
|
| 84 |
+
Item : identifier of the item purchased (see goods.Id)
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
**************************************************************************
|
| 89 |
+
|
| 90 |
+
reciepts.csv
|
| 91 |
+
|
| 92 |
+
RecieptNumber : unique identifier of the reciept
|
| 93 |
+
Date : date of the purchase. The date is
|
| 94 |
+
in DD-Mon-YYY format, which is the
|
| 95 |
+
default Oracle's format for DATE data type.
|
| 96 |
+
CustomerId : id of the customer (see customers.Id)
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
**************************************************************************
|
| 100 |
+
**************************************************************************
|
| 101 |
+
|
| 102 |
+
Permission granted to use and distribute this dataset in its current form,
|
| 103 |
+
provided this file is kept unchanged and is distributed together with the
|
| 104 |
+
data.
|
| 105 |
+
|
| 106 |
+
Permission granted to modify and expand this dataset, provided this
|
| 107 |
+
file is updated accordingly with new information.
|
| 108 |
+
|
| 109 |
+
**************************************************************************
|
| 110 |
+
**************************************************************************
|
test_database/bakery_1/data_csv/customers.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4fa3ff7fe166ed5532eaa19938c5be357335fe82dad84ad5825a2562dba2668b
|
| 3 |
+
size 490
|
test_database/bakery_1/data_csv/customers_t.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:873596b8573f92372c6354f62d348d8150bf186a9b9b163801a663ed754c2110
|
| 3 |
+
size 368
|
test_database/bakery_1/data_csv/goods.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0676f451bf024fde17687d84c56196bc266bca69713bddf6577711df986d43ae
|
| 3 |
+
size 1411
|
test_database/bakery_1/data_csv/goods_t.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f330742d8a5e312ba1d5a84d06a44f4eb9d05cc5c5eccedf824bb9674766dac4
|
| 3 |
+
size 1171
|
test_database/bakery_1/data_csv/items (3:11:18, 5:53 PM)_original.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:20b755b8d33b14fb87e922c6869f9fe51cf85811b991de41d674850a4571b1e6
|
| 3 |
+
size 11817
|
test_database/bakery_1/data_csv/items.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:90323310375d4d72b3a7e97d503afb78a1674c6944474195c8d48504301dbc26
|
| 3 |
+
size 11817
|
test_database/bakery_1/data_csv/items_t.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a692759e583e70eec78dd4e8947f15b6d8046c5df3c7d31893e5e88c840dce6c
|
| 3 |
+
size 9030
|
test_database/bakery_1/data_csv/receipts (3:11:18, 5:53 PM)_original.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:eee2a10433b03b832649c0d41ef467efc0bb430afcec10452cfa73255971d377
|
| 3 |
+
size 4883
|
test_database/bakery_1/data_csv/receipts.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c83039e0c6e4271862d128f474051ba500f97ca15edcfce88e82b9f47dff32b6
|
| 3 |
+
size 4883
|
test_database/bakery_1/data_csv/receipts_t.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:16f643a31ccce616a3c94620278de4c7119b60dc64ffc644cd0a1fe2bb3aa873
|
| 3 |
+
size 4081
|
test_database/bakery_1/link.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
http://users.csc.calpoly.edu/~dekhtyar/365-Spring2017/index.html
|
test_database/bakery_1/q.txt
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Find all chocolate-flavored items on the menu whose price is under $5.00. For each item output the flavor, the name (food type) of the item, and the price.
|
| 2 |
+
|
| 3 |
+
Report the prices of any lemon-flavored items. Output the flavor, the name (food type) and the price of each pastry.
|
| 4 |
+
|
| 5 |
+
Find all customers who made a purchase on October 3, 2007. Report the name of the customer (first, last).
|
| 6 |
+
|
| 7 |
+
Find all types of cookies purchased by KIP ARNN during the month of October of 2007. Report each cookie type (flavor, food type) exactly once.
|
| 8 |
+
|
| 9 |
+
Report the total amount of money NATACHA STENZ spent at the bakery during the month of October, 2007.
|
| 10 |
+
|
| 11 |
+
Find all customers who purchased, during the same trip to the bakery, two different Croissants. Report first and last names of the customers.
|
| 12 |
+
|
| 13 |
+
Find the total amount of money the bakery earned in October 2007 from selling eclairs. Report just the amount.
|
| 14 |
+
|
| 15 |
+
Report all days on which more than ten tarts were purchased.
|
| 16 |
+
|
| 17 |
+
For each purchase made by NATACHA STENZ output the receipt number, the date of purchase, the total number of items purchased and the amount paid.
|
| 18 |
+
|
| 19 |
+
Find the customer(s) who spent the most on pastries in October of 2007. Report first and last name.
|
| 20 |
+
|
| 21 |
+
Find the type of baked good (food type, flavor) responsible for highest total revenue.
|
| 22 |
+
|
| 23 |
+
Find the day of the highest revenue in the month of October, 2007.
|
| 24 |
+
|
| 25 |
+
Find the best-selling item (by number of purchases) on the day of the highest revenue in October of 2007.
|
test_database/bbc_channels/bbc_channels.sqlite
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1b9a7e6de6706734736e869180334b35420de138b1ee47b0b0f7822758cbf01a
|
| 3 |
+
size 36864
|
test_database/bbc_channels/schema.sql
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b77ce8175e7f333f662c52bf79817596cd881d6fbe9b4d02a5c10e85d626ba9b
|
| 3 |
+
size 3235
|
test_database/bike_racing/bike_racing.sqlite
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5d485e48c937b87f80c4e2bcc588d88042b1f52b8596b1f47afa33da674c8a5d
|
| 3 |
+
size 28672
|
test_database/bike_racing/schema.sql
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:65f36652dd91fecafb140b167c9924a83ebf3e0413ea9a2095eb5d95c8592952
|
| 3 |
+
size 2436
|
test_database/bike_racing/schema_old.sql
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5f9eb86f1e82b40eeb1e6c014709c997d0708f13bfc68048f26627799ac85ddf
|
| 3 |
+
size 2436
|
test_database/boat_1/Boats.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:05b90485f1752cc133d04391e011b8b604f2a391c8b270e8533057cb2d0059fe
|
| 3 |
+
size 58
|
test_database/boat_1/Reserves.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:86eac26ef3ef915c403628c6d6edf8cb89e0a6c11ec509774703fcc410a6b45d
|
| 3 |
+
size 56
|
test_database/boat_1/Sailors.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:586d1cb0034162eb8aeb941939f41aaf441b567da8c1f088cdc9f8ef267fd61a
|
| 3 |
+
size 61
|
test_database/boat_1/boat_1.sqlite
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b9305054e2a29c18cdbfbe2306a27c15ba01c67085e1b72745e7e01e5336a98c
|
| 3 |
+
size 16384
|
test_database/boat_1/schema.sql
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3dd083ae5788c770cf0fcf8a4cf9f125d87190ebbd34ee2d280ae0709e44991d
|
| 3 |
+
size 325
|
test_database/book_1/annotation.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ed4db6daed1b9922a66e3749644927f9c9ba663209f55659e54a8229895780f0
|
| 3 |
+
size 5554
|
test_database/book_1/book_1.sqlite
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ab0fcc505f150d8904d62f639cfcbd01497ef755bb5926ed2acff3152eb662a2
|
| 3 |
+
size 53248
|
test_database/book_1/link.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
https://github.com/ferreiro/SQL-Oracle-databases/blob/master/2_SQL_Queries/Block1%20(AllTheBooks%20Table).sql
|
test_database/book_1/q.txt
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
List of books, the publication year of each of them and their authors, ordered by publication year
|
| 2 |
+
|
| 3 |
+
List of books that were published before 01-01-2000.
|
| 4 |
+
|
| 5 |
+
List of clients that have bought at least one book.
|
| 6 |
+
|
| 7 |
+
List of clients that bought the book whose ISBN= 4554672899910.
|
| 8 |
+
|
| 9 |
+
List of clients whose name contains ‘Jo’ and the books that they have bought.
|
| 10 |
+
|
| 11 |
+
List of clients that have bought at least a book whose price is greater than 10.
|
| 12 |
+
|
| 13 |
+
List of clients that have placed more than one order in the same date.
|
| 14 |
+
|
| 15 |
+
List of clients and dates in which they have placed orders that have not been sent yet.
|
| 16 |
+
|
| 17 |
+
List of clients that have not bought books whose price is greater than 10.
|
| 18 |
+
|
| 19 |
+
List of books whose sale price is greater than 30€ or that were published before 2000.
|
| 20 |
+
|
| 21 |
+
List of books and amount of copies of each of them that have been sold.
|
| 22 |
+
|
| 23 |
+
List of clients and the total amount that they have spent in the bookstore.
|
| 24 |
+
|
| 25 |
+
Profits obtained from sales of books.
|
| 26 |
+
|
| 27 |
+
Orders whose total amount is greater than 100.
|
| 28 |
+
|
| 29 |
+
Orders and the total amount of each of them that contains more than a book (title).
|
| 30 |
+
|
| 31 |
+
Orders and the total amount of each of them that contains more than 4 copies
|
| 32 |
+
|
| 33 |
+
List of the most expensive books.
|
| 34 |
+
|
| 35 |
+
List of books that have not been sold or that have been sold but the profit per copy is less than 5
|
| 36 |
+
|
| 37 |
+
List of clients that have bought more than one copy of a book sometime
|
test_database/book_1/schema.sql
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1a80236ad41dc1d434fd5917b00b53fd50c3899816df026cad8bb76f71d3d6c2
|
| 3 |
+
size 4218
|
test_database/book_1/schema_old.sql
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:58f57222f82dabd3b8d95b554a51ed3dbc35251c1aa714821257b2a15292449f
|
| 3 |
+
size 4178
|
test_database/book_1/sql.txt
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
SELECT TITLE, AÑO "YEAR", NAME "Author name"
|
| 2 |
+
FROM BOOK NATURAL JOIN AUTHOR_BOOK, AUTHOR
|
| 3 |
+
WHERE AUTHOR_BOOK.AUTHOR=AUTHOR.IDAUTHOR
|
| 4 |
+
ORDER BY AÑO;
|
| 5 |
+
|
| 6 |
+
SELECT TITLE, AÑO
|
| 7 |
+
FROM BOOK
|
| 8 |
+
WHERE AÑO<'2000';
|
| 9 |
+
|
| 10 |
+
SELECT DISTINCT IDCLIENT, NAME
|
| 11 |
+
FROM CLIENT NATURAL JOIN ORDERS;
|
| 12 |
+
select distinct client.name, Client.IdClient
|
| 13 |
+
from Client, Orders where
|
| 14 |
+
Client.IdClient=Orders.IdClient;
|
| 15 |
+
|
| 16 |
+
SELECT IDCLIENT, NAME
|
| 17 |
+
FROM CLIENT NATURAL JOIN ORDERS NATURAL JOIN BOOKS_ORDER
|
| 18 |
+
WHERE ISBN='4554672899910';
|
| 19 |
+
|
| 20 |
+
SELECT IDCLIENT, NAME, TITLE
|
| 21 |
+
FROM CLIENT NATURAL JOIN ORDERS NATURAL JOIN BOOKS_ORDER NATURAL JOIN BOOK
|
| 22 |
+
WHERE NAME LIKE '%Jo%';
|
| 23 |
+
|
| 24 |
+
SELECT DISTINCT IDCLIENT, NAME
|
| 25 |
+
FROM CLIENT NATURAL JOIN ORDERS NATURAL JOIN BOOKS_ORDER NATURAL JOIN BOOK
|
| 26 |
+
WHERE BOOK.SALEPRICE>10;
|
| 27 |
+
|
| 28 |
+
SELECT IDCLIENT, NAME
|
| 29 |
+
FROM CLIENT
|
| 30 |
+
WHERE IDCLIENT=(
|
| 31 |
+
SELECT IDCLIENT
|
| 32 |
+
FROM ORDERS
|
| 33 |
+
GROUP BY(IDCLIENT,DATEORDER)
|
| 34 |
+
HAVING COUNT(DATEORDER)>1
|
| 35 |
+
);
|
| 36 |
+
|
| 37 |
+
SELECT IDCLIENT, NAME, DATEORDER
|
| 38 |
+
FROM CLIENT NATURAL JOIN ORDERS
|
| 39 |
+
WHERE DATEEXPED IS NULL;
|
| 40 |
+
|
| 41 |
+
SELECT DISTINCT IDCLIENT, NAME
|
| 42 |
+
FROM CLIENT
|
| 43 |
+
WHERE IDCLIENT NOT IN (
|
| 44 |
+
SELECT IDCLIENT
|
| 45 |
+
FROM ORDERS NATURAL JOIN BOOKS_ORDER NATURAL JOIN BOOK
|
| 46 |
+
WHERE SALEPRICE < 10
|
| 47 |
+
);
|
| 48 |
+
|
| 49 |
+
SELECT TITLE, AÑO, SALEPRICE
|
| 50 |
+
FROM BOOK
|
| 51 |
+
WHERE AÑO<'2000' OR SALEPRICE>30;
|
| 52 |
+
|
| 53 |
+
SELECT TITLE, ISBN, SUM(AMOUNT)
|
| 54 |
+
FROM BOOKS_ORDER NATURAL JOIN BOOK
|
| 55 |
+
GROUP BY TITLE, ISBN
|
| 56 |
+
ORDER BY SUM(AMOUNT) DESC;
|
| 57 |
+
|
| 58 |
+
SELECT IDCLIENT, NAME, SUM(AMOUNT*SALEPRICE) "Total"
|
| 59 |
+
FROM CLIENT NATURAL JOIN ORDERS NATURAL JOIN BOOKS_ORDER NATURAL JOIN BOOK
|
| 60 |
+
GROUP BY IDCLIENT, NAME;
|
| 61 |
+
|
| 62 |
+
SELECT SUM(AMOUNT*(SALEPRICE-PURCHASEPRICE)) "Total"
|
| 63 |
+
FROM BOOKS_ORDER NATURAL JOIN BOOK;
|
| 64 |
+
|
| 65 |
+
SELECT IDORDER, SUM(AMOUNT*SALEPRICE) "TOTAL"
|
| 66 |
+
FROM BOOKS_ORDER NATURAL JOIN BOOK
|
| 67 |
+
GROUP BY IDORDER
|
| 68 |
+
HAVING SUM(AMOUNT*SALEPRICE)>100
|
| 69 |
+
ORDER BY IDORDER;
|
| 70 |
+
|
| 71 |
+
SELECT IDORDER, SUM(AMOUNT*SALEPRICE) "TOTAL"
|
| 72 |
+
FROM BOOKS_ORDER NATURAL JOIN BOOK
|
| 73 |
+
GROUP BY IDORDER
|
| 74 |
+
HAVING COUNT(TITLE)>1;
|
| 75 |
+
|
| 76 |
+
SELECT IDORDER, SUM(AMOUNT*SALEPRICE) "Total"
|
| 77 |
+
FROM BOOKS_ORDER NATURAL JOIN BOOK
|
| 78 |
+
WHERE AMOUNT>4
|
| 79 |
+
GROUP BY IDORDER;
|
| 80 |
+
|
| 81 |
+
SELECT ISBN, TITLE, SALEPRICE
|
| 82 |
+
FROM BOOK
|
| 83 |
+
WHERE SALEPRICE IN (SELECT MAX(SALEPRICE) FROM BOOK);
|
| 84 |
+
|
| 85 |
+
SELECT ISBN, TITLE
|
| 86 |
+
FROM BOOK
|
| 87 |
+
WHERE(SALEPRICE-PURCHASEPRICE)<5 OR ISBN NOT IN(
|
| 88 |
+
SELECT DISTINCT ISBN FROM BOOKS_ORDER
|
| 89 |
+
);
|
| 90 |
+
|
| 91 |
+
SELECT NAME
|
| 92 |
+
FROM CLIENT NATURAL JOIN ORDERS
|
| 93 |
+
WHERE IDORDER IN (
|
| 94 |
+
SELECT IDORDER
|
| 95 |
+
FROM BOOKS_ORDER
|
| 96 |
+
WHERE AMOUNT>1
|
| 97 |
+
);
|
test_database/book_press/book_press.sqlite
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c8748351b418fb213f3e4871471f8b923011323df6d341fb96796bb36f466acb
|
| 3 |
+
size 28672
|
test_database/book_press/schema.sql
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fc7be7bf9a543731039083f8d3166baa6b97eb2a9b22187d91257b6d372c7450
|
| 3 |
+
size 2416
|
test_database/book_review/book_review.sqlite
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ed22389124512c73025037cf2e5546e1225e78a6f5a9db052a3aa635b93fba31
|
| 3 |
+
size 20480
|