Student Learning Objectives
After successful completion of this assignment the student will be able to:
Use BigQuery to query public datasets.
Write queries using aggregate functions, grouping, ordering, and subqueries.
Important Notes about Grading
A reminder, any syntax error, including missing semi-colon at the end of even one SQL statement, will result in a grade of 0 for the entire assignment.
Further each question will be graded in a binary fashion. That is, if it is correct you will get full marks for that question. If there is any problem with your code (except a syntax error) you will receive a grade of 0 for that question.
Requirements
First there must be no syntax errors in any of the code submitted, that includes missing a semi-colon at the end of any SQL statement. Any syntax error (even one) will result in a grade of 0 for the entire assignment.
In a file named baby_names.sql, you will put all your SQL code for this assignment.
Your SQL statement answers to each of the questions must be numbered in order as comments, as below:
— Q1
your code for Q1 here;
— Q2
your code for Q2 here;
etc.
Pay attention to the definite article a, such as in “write a SQL query,” which means write only 1 SQL statement.
If you provide more than one answer/statement for any question, that question will receive a grade of 0..
In the case there are multiple results columns they must appear in the order specified.
Questions
Here are the questions for the code that you must write to query the Google Cloud USA Names Public Dataset (Links to an external site.). Please refer to the schema (below) which should assist you in determining the correct columns.usa-names-schema.png
Write a SQL query to find the total number of records with the result labelled record_count
Write a SQL query to find the total number of boys and the total number of girls born/named, containing the columns (and labels) and rows as shown below. NOTE you may not hard code in the birth numbers, you must get them through proper grouping and aggregate function(s). Your output should be sorted on the gender column as shown below.
q2-result.png
Write a SQL query to find:
the fewest number of occurrences of any name, labelled fewest_num,
the average number of occurrences of any name, rounded to the nearest whole number, labelled as avg_num,
and the most number of occurrences of any name, labelled most_num,
grouped by state
and sorted by most number of occurrences of any name, from highest to least.
IMPORTANT NOTE there should be no where clause, finding the correct entry must come from using aggregate functions, grouping, and ordering.
q3-partial-result.png
Using the highest most_num and its state value found in question 3, write a SQL query that just finds the given name of that person at birth. NOTE you may hardcode in the state and most_num values. HINT you may use a simple where or having (Links to an external site.). You may not use >, >=, <. or <=. You must find an exact match. Your result will have a single column, named name, with a single result.
Write a SQL query with a subquery to find
most popular baby name in Florida, labelled name
and the total number of occurrences of that name , labelled total
HINT You may want to work on your subquery first, to verify that the subquery is syntactically correct and that it selects the most popular baby name in Florida.
IMPORTANT NOTE You must use a subquery to find the most popular baby name in Florida. If you do not use the subquery to find this and instead, for example, hardcode values, you will receive 0 for this question.
q5-partial-result.png
What to Submit
Submit your baby_names.sql as an attachment to this assignment.
Rubric
Baby Names Rubric
Baby Names Rubric
Criteria Ratings Pts
This criterion is linked to a Learning OutcomeExtra Credit — early submission
Refer to Course Syllabus for eligibility timeframe
0.0 pts
+5 Extra Credit — early submission
Refer to Course Syllabus for eligibility timeframe
0.0 pts
No Marks
0.0 pts
This criterion is linked to a Learning OutcomeQuestion 1
22.0 pts
Full Marks
0.0 pts
No Marks
22.0 pts
This criterion is linked to a Learning OutcomeQuestion 2
22.0 pts
Full Marks
0.0 pts
No Marks
22.0 pts
This criterion is linked to a Learning OutcomeQuestion 3
22.0 pts
Full Marks
0.0 pts
No Marks
22.0 pts
This criterion is linked to a Learning OutcomeQuestion 4
22.0 pts
Full Marks
0.0 pts
No Marks
22.0 pts
This criterion is linked to a Learning OutcomeQuestion 5
12.0 pts
Full Marks
0.0 pts
No Marks
12.0 pts
Total Points: 100.0