Match the query

  1. 1B
  2. 2A
  3. 3C
  4. 4B
  5. 5B
  6. 6A
  7. 7B
  8. 8C
  9. 9A
  10. 10B
  11. 11B

Write out the query

1.

SELECT *
FROM homes
WHERE 
  owner_name = 'Carolina';

2.

SELECT * 
FROM people
WHERE sex = 'M' 
ORDER BY 
  age DESC

3.

SELECT SUM(value)
FROM homes;

4.

SELECT eyes, 
  COUNT(*) AS the_count
FROM people
GROUP BY eyes
ORDER BY the_count ASC

5.

SELECT homes.*
FROM homes
INNER JOIN 
  people ON
  people.name = homes.owner_name
WHERE people.eyes = 'brown'
  AND people.sex = 'M';

Twitter joining

T1.

SELECT COUNT(*) AS tcount
FROM tweets
WHERE text LIKE '%vote%'

T2 (Extra credit).

SELECT tag, 
  COUNT(*) AS hcount
FROM tw_hashtags
INNER JOIN 
  tweets ON
    tweets.ID = tw_hashtags.tweet_ID
WHERE tweets.screen_name = 'realdonaldtrump'
  AND STRFTIME('%H', time_tweeted) BETWEEN '00' AND '05'
GROUP BY tag
ORDER BY hcount DESC
LIMIT 5;

Police-officer involved shootings

P1.

SELECT "PERSON RACE", 
  "DEPUTY RACE", 
  COUNT(*) AS icount
FROM deputies
  INNER JOIN people
    ON
      deputies."INCIDENT NUMBER" = people."INCIDENT NUMBER"
GROUP BY 
  "PERSON RACE", "DEPUTY RACE"
ORDER BY 
  icount DESC