Day 2: SQL Calculations

Welcome to class!

Gratitude Journal

Announcements


Class Activity in Slack

Part 1

Goal: Describe in words (NOT using code) how to get from your starting data to your ending data.

Post your answer in your group’s Slack thread. You have 7 minutes, and are allowed to ask me 1 question.

Part 2

Goal: Now try to write a SQL query to get your ending data.

Post your SQL query in your group’s Slack thread. You have 7 minutes, and are allowed to ask me 1 question.

Here is the SQL template for your use.

SELECT -- <columns> and <column calculations>
FROM -- <table name>
  JOIN -- <table name>
  ON -- <columns to join>
WHERE -- <filter condition>
GROUP BY -- <subsets for column calculations>
HAVING -- <grouped filter condition>
ORDER BY -- <how the output is returned in sequence>
LIMIT -- <number of rows to return>


Getting started

Question One: Write an SQL query to create a new dataframe about baseball players who attended BYU-Idaho. The new table should contain five columns: playerID, schoolID, salary, and the yearID/teamID associated with each salary. Order the table by salary (highest to lowest) and print out the table in your report.

Think about:

  • What tables (data) do you need?
  • What SQL commands do you need?

Extra Practice

“I get SQL and want to be challenged.”

Do this Math 335 task with SQL commands in Python.