Skip to content

Commit 5c0ae02

Browse files
authored
Merge pull request #612 from brymz/sql-review
Sql-practice-basic-queries-review: revise for content & clarity; add output solns
2 parents 564174c + 98b61d0 commit 5c0ae02

4 files changed

+53
-7
lines changed

exercises/Sql-practice-basic-queries-review-R.md

+10-7
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ This is a follow-up to [Introduction to Databases]({{ site.baseurl }}/assignment
99

1010
Download the [`sql-practice.sqlite` database]({{ site.baseurl }}/data/sql-practice.sqlite). Open it in SQLite Manager and write a query for each of the following:
1111

12-
*When writing the solution to each review problem, take a second to think carefully about which fields are actually relevant to the problem. Write your query so that only these relevant fields are selected for the final output. In other words, if you are going to do some form of analysis with the data you select, which fields do you actually need?* (**HINT: none of these problems should have SELECT \* in the answer.**)
13-
14-
1. Write a query that lists all the males in order by weight, starting with the heaviest.
15-
16-
2. Write a query that lists all males with a weight greater than 10 and all females with a weight less than 10.
17-
18-
3. Write a query that displays the number of females at each site. Name the field with the number of females something meaningful.
12+
*When writing the query to satisfy each research question, take a second to
13+
think carefully about which fields are actually relevant. Write your query so
14+
that only these relevant fields are selected for the final output. In other
15+
words, if you are going to continue with an analysis of the data you select,
16+
which fields do you actually need?* (**HINT: none of these problems should have
17+
SELECT \* in the answer.**)
18+
19+
1. What is the distribution of males and females that weigh greater than 10?
20+
2. Where (*in what sites*) are the 10 heaviest males?
21+
3. How many females are at each site?
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"sex","weight"
2+
"F","12"
3+
"M","11"
4+
"F","14"
5+
"F","14"
6+
"M","14"
7+
"M","13"
8+
"F","13"
9+
"M","14"
10+
"M","15"
11+
"F","11"
12+
"F","15"
13+
"M","13"
14+
"F","12"
15+
"M","11"
16+
"M","13"
17+
"F","11"
18+
"M","15"
19+
"M","13"
20+
"M","12"
21+
"F","14"
22+
"M","12"
23+
"F","13"
24+
"M","12"
25+
"F","13"
26+
"M","12"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"site"
2+
"E"
3+
"A"
4+
"A"
5+
"A"
6+
"D"
7+
"D"
8+
"E"
9+
"D"
10+
"D"
11+
"D"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"site","count_female"
2+
"A","2"
3+
"B","6"
4+
"C","4"
5+
"D","5"
6+
"E","5"

0 commit comments

Comments
 (0)