{
 "keys_file_sha256": "0bc8c95a50be096311387c08c659f9556fdd72bec5217c46efa9b44deab9285e",
 "readings_file_sha256": "6813874ed90959853bb71a292cb6776d3ab2ba458d06cbc7124bc8f211106c5e",
 "questions": [
  {
   "id": "B01",
   "author_reading": "Count every row in trips, including rows with missing values. Return an integer.",
   "reading_sql": "SELECT COUNT(*) AS trips FROM trips",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B02",
   "author_reading": "Add fare across all trips, leaving out missing fares. Return null if no fares are recorded. Round the result to two decimal places.",
   "reading_sql": "SELECT ROUND(SUM(fare), 2) AS fare_revenue FROM trips",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B03",
   "author_reading": "Divide the sum of recorded fares by the number of trips with a recorded fare, including zero fares. Return null if there are none. Round to two decimal places.",
   "reading_sql": "SELECT ROUND(AVG(fare), 2) AS avg_fare FROM trips WHERE fare IS NOT NULL",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B04",
   "author_reading": "Average the nonmissing trip_seconds values across all trips, then convert seconds to minutes by dividing by 60. Return null if none are recorded. Round only the final value to two decimal places.",
   "reading_sql": "SELECT ROUND(AVG(trip_seconds) / 60.0, 2) AS avg_minutes FROM trips",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B05",
   "author_reading": "Add all nonmissing trip_miles values. Do not round. Return null if no mileage values are recorded.",
   "reading_sql": "SELECT SUM(trip_miles) AS miles FROM trips",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B06",
   "author_reading": "Count trips whose tip is strictly positive. Exclude missing, zero, and negative tips. Cash tips are outside this measure.",
   "reading_sql": "SELECT COUNT(*) AS trips FROM trips WHERE tip > 0",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B07",
   "author_reading": "Count trips where fare is missing. A recorded fare of zero is not missing.",
   "reading_sql": "SELECT COUNT(*) AS trips FROM trips WHERE fare IS NULL",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B08",
   "author_reading": "Count trips with trip_miles strictly greater than 10. Exclude trips with missing mileage.",
   "reading_sql": "SELECT COUNT(*) AS trips FROM trips WHERE trip_miles > 10",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B09",
   "author_reading": "Count trips whose shared_trip_match flag is true, regardless of whether sharing was authorized.",
   "reading_sql": "SELECT COUNT(*) AS trips FROM trips WHERE shared_trip_match",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B10",
   "author_reading": "Count trips with shared_trip_match true and shared_trip_authorized false. Missing authorization does not qualify.",
   "reading_sql": "SELECT COUNT(*) AS trips FROM trips WHERE shared_trip_match AND shared_trip_authorized = FALSE",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B11",
   "author_reading": "Count trips whose pickup and dropoff zone identifiers are equal and between 1 and 77. Missing identifiers and zone 0 do not qualify.",
   "reading_sql": "SELECT COUNT(*) AS trips FROM trips WHERE pickup_zone_id = dropoff_zone_id AND pickup_zone_id <> 0",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B12",
   "author_reading": "Find the largest nonmissing trip_total value. Return null if none are recorded. Do not round or reconstruct the amount from its components.",
   "reading_sql": "SELECT MAX(trip_total) AS largest_total FROM trips",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B13",
   "author_reading": "Group trips by trip_date and count every trip in each group. Return one row per observed date, ordered earliest first.",
   "reading_sql": "SELECT trip_date, COUNT(*) AS trips FROM trips GROUP BY 1 ORDER BY 1",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B14",
   "author_reading": "Group all trips by date. Count nonmissing fares and average those fares, including zero fares. Keep dates with no recorded fares, showing a count of zero and a null average. Round averages to two decimal places.",
   "reading_sql": "SELECT trip_date, COUNT(fare) AS fares, ROUND(AVG(fare), 2) AS avg_fare FROM trips GROUP BY 1 ORDER BY 1",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B15",
   "author_reading": "Assign each sampled trip to the Monday beginning its calendar week. Count trips by that date. Do not bring in February trips or adjust the partial week. Return the week start as a date.",
   "reading_sql": "SELECT DATE_TRUNC('week', trip_date) AS week_monday, COUNT(*) AS trips FROM trips GROUP BY 1 ORDER BY 1",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B16",
   "author_reading": "Determine each trip date's weekday and total trips across all occurrences of that weekday. This is total volume, not average volume per calendar day. Return observed weekdays only, using the specified numbering and order.",
   "reading_sql": "SELECT EXTRACT(isodow FROM trip_date) AS weekday, COUNT(*) AS trips FROM trips GROUP BY 1 ORDER BY trips DESC, weekday",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B17",
   "author_reading": "Group trips with a nonmissing pickup zone identifier by that identifier and count all trips. Include zone 0. Sort by count descending and identifier ascending, then keep at most 10 rows.",
   "reading_sql": "SELECT pickup_zone_id, COUNT(*) AS trips FROM trips GROUP BY 1 ORDER BY trips DESC, pickup_zone_id LIMIT 10",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B18",
   "author_reading": "Keep trips with dropoff zone identifiers from 1 through 77. Count trips per dropoff zone, sort by count descending and identifier ascending, and return at most 10 rows.",
   "reading_sql": "SELECT dropoff_zone_id, COUNT(*) AS trips FROM trips WHERE dropoff_zone_id <> 0 GROUP BY 1 ORDER BY trips DESC, dropoff_zone_id LIMIT 10",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B19",
   "author_reading": "Group trips by shared_trip_match after excluding missing flags. Count all trips and nonmissing fares separately. Average recorded fares within each group, including zero fares; show null if a group has no recorded fares. Return only groups present, with false first.",
   "reading_sql": "SELECT shared_trip_match, COUNT(*) AS trips, COUNT(fare) AS fares, ROUND(AVG(fare), 2) AS avg_fare FROM trips WHERE shared_trip_match IS NOT NULL GROUP BY 1 ORDER BY 1",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B20",
   "author_reading": "Group trips with nonmissing shared_trip_authorized by that flag. Count every trip in each group and separately count those whose shared_trip_match is true. Missing match flags contribute to the total but not the shared count. Return only observed authorization groups.",
   "reading_sql": "SELECT shared_trip_authorized, COUNT(*) AS trips, SUM(CASE WHEN shared_trip_match THEN 1 ELSE 0 END) AS shared FROM trips WHERE shared_trip_authorized IS NOT NULL GROUP BY 1 ORDER BY 1",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B21",
   "author_reading": "Keep trips where both sharing flags are nonmissing. Count trips for each observed pair of boolean values. Do not create absent combinations. Return at most four rows in the requested order.",
   "reading_sql": "SELECT shared_trip_authorized, shared_trip_match, COUNT(*) AS trips FROM trips WHERE shared_trip_authorized IS NOT NULL AND shared_trip_match IS NOT NULL GROUP BY 1, 2 ORDER BY 1, 2",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B22",
   "author_reading": "Group trips by date. Count all trips and add nonmissing trip_miles within each date. A date with no recorded mileage has a null miles total. Do not round.",
   "reading_sql": "SELECT trip_date, COUNT(*) AS trips, SUM(trip_miles) AS miles FROM trips GROUP BY 1 ORDER BY 1",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B23",
   "author_reading": "Group trips by the weekday of trip_date. Average nonmissing trip_seconds across individual trips in each weekday group, then divide by 60. This is not an average of daily averages. Return null if a group has no recorded durations and round final averages to two decimal places.",
   "reading_sql": "SELECT EXTRACT(isodow FROM trip_date) AS weekday, ROUND(AVG(trip_seconds) / 60.0, 2) AS avg_minutes FROM trips GROUP BY 1 ORDER BY 1",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B24",
   "author_reading": "Keep pickup zones 1 through 77. For each zone, count nonmissing mileage values and average them, including zeros. Keep zones with at least 20 such trips. Sort using the unrounded average and then the zone identifier, keep at most 10, and round displayed averages to two decimal places.",
   "reading_sql": "SELECT pickup_zone_id, COUNT(trip_miles) AS trips, ROUND(AVG(trip_miles), 2) AS avg_miles FROM trips WHERE pickup_zone_id <> 0 GROUP BY 1 HAVING COUNT(trip_miles) >= 20 ORDER BY AVG(trip_miles) DESC, pickup_zone_id LIMIT 10",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B25",
   "author_reading": "Classify trips by trip_date into Monday through Friday or Saturday and Sunday. Count all trips and nonmissing trip_total values in each observed group. Average only recorded trip totals, including zero values. Show null if a group has none and round averages to two decimal places.",
   "reading_sql": "SELECT CASE WHEN EXTRACT(isodow FROM trip_date) IN (6, 7) THEN 'Weekend' ELSE 'Weekday' END AS day_type, COUNT(*) AS trips, COUNT(trip_total) AS totals, ROUND(AVG(trip_total), 2) AS avg_total FROM trips GROUP BY 1 ORDER BY 1",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B26",
   "author_reading": "Place each trip into exactly one band: recorded mileage below 3, mileage at least 3 but below 10, mileage at least 10, or missing mileage. Count trips per observed band and use the specified order. Any recorded negative mileage belongs in the first band.",
   "reading_sql": "WITH b AS (SELECT CASE WHEN trip_miles IS NULL THEN 'Mileage missing' WHEN trip_miles < 3 THEN 'Under 3 miles' WHEN trip_miles < 10 THEN '3 to under 10 miles' ELSE '10 miles or more' END AS band, CASE WHEN trip_miles IS NULL THEN 4 WHEN trip_miles < 3 THEN 1 WHEN trip_miles < 10 THEN 2 ELSE 3 END AS k FROM trips) SELECT band, COUNT(*) AS trips FROM b GROUP BY band, k ORDER BY k",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B27",
   "author_reading": "Match trips.pickup_zone_id to zones.zone_id, retaining matched trips, including zone 0. Group by zone identifier and name and count trips. Sort by count descending, name ascending, and identifier ascending; return at most 10 rows.",
   "reading_sql": "SELECT t.pickup_zone_id, z.zone_name, COUNT(*) AS trips FROM trips t JOIN zones z ON z.zone_id = t.pickup_zone_id GROUP BY 1, 2 ORDER BY trips DESC, z.zone_name, t.pickup_zone_id LIMIT 10",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B28",
   "author_reading": "Keep trips whose pickup and dropoff identifiers are both between 1 and 77. Match each endpoint to its own zones lookup. Count trips by the ordered pair of endpoints, including equal endpoints. Sort as specified and return at most 10 routes.",
   "reading_sql": "SELECT t.pickup_zone_id, p.zone_name, t.dropoff_zone_id, d.zone_name, COUNT(*) AS trips FROM trips t JOIN zones p ON p.zone_id = t.pickup_zone_id JOIN zones d ON d.zone_id = t.dropoff_zone_id WHERE t.pickup_zone_id <> 0 AND t.dropoff_zone_id <> 0 GROUP BY 1, 2, 3, 4 ORDER BY trips DESC, t.pickup_zone_id, t.dropoff_zone_id LIMIT 10",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B29",
   "author_reading": "Keep trips with authorization true and pickup identifiers 1 through 77, and match pickup identifiers to zones. For each area, the denominator is every authorized trip and the numerator is those with actual-sharing flag true. Missing match flags remain in the denominator. Keep denominators of at least 20, multiply the ratio by 100, and round only the displayed percentage.",
   "reading_sql": "WITH a AS (SELECT pickup_zone_id, COUNT(*) AS n, SUM(CASE WHEN shared_trip_match THEN 1 ELSE 0 END) AS m FROM trips WHERE shared_trip_authorized AND pickup_zone_id <> 0 GROUP BY 1) SELECT a.pickup_zone_id, z.zone_name, n, m, ROUND(100.0 * m / n, 2) AS pct FROM a JOIN zones z ON z.zone_id = a.pickup_zone_id WHERE n >= 20 ORDER BY 100.0 * m / n DESC, a.pickup_zone_id",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B30",
   "author_reading": "The denominator is the count of trips with shared_trip_match true. The numerator counts those same trips whose shared_trip_authorized is false. Missing authorization stays in the denominator but not the numerator. Multiply by 100 and round to two decimal places; a zero denominator yields null.",
   "reading_sql": "SELECT ROUND(100.0 * SUM(CASE WHEN shared_trip_authorized = FALSE THEN 1 ELSE 0 END) / NULLIF(COUNT(*), 0), 2) AS pct FROM trips WHERE shared_trip_match",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B31",
   "author_reading": "Start with all 78 rows in zones and attach pickup counts from trips by matching zone identifiers. Preserve every directory row. Count actual matching trips only and use zero when none match. Return the identifier, name, and integer count.",
   "reading_sql": "SELECT z.zone_id, z.zone_name, COUNT(t.trip_id) AS pickups FROM zones z LEFT JOIN trips t ON t.pickup_zone_id = z.zone_id GROUP BY 1, 2 ORDER BY 1",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B32",
   "author_reading": "Group trips by date. The denominator counts all trips, including missing sharing flags; the numerator counts shared_trip_match true. Keep dates with at least 50 trips, calculate the percentage, sort using its unrounded value and then date ascending, and return at most five rows. Round displayed percentages to two decimal places.",
   "reading_sql": "WITH d AS (SELECT trip_date, COUNT(*) AS n, SUM(CASE WHEN shared_trip_match THEN 1 ELSE 0 END) AS m FROM trips GROUP BY 1) SELECT trip_date, n, m, ROUND(100.0 * m / n, 2) AS pct FROM d WHERE n >= 50 ORDER BY 100.0 * m / n DESC, trip_date LIMIT 5",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B33",
   "author_reading": "Separately average nonmissing fares for shared_trip_match true and shared_trip_match false, including recorded zero fares. Exclude missing match flags from both groups. Subtract the false group's unrounded average from the true group's unrounded average, then round the difference to two decimal places. Missing either average yields null.",
   "reading_sql": "SELECT ROUND(AVG(CASE WHEN shared_trip_match THEN fare END) - AVG(CASE WHEN shared_trip_match = FALSE THEN fare END), 2) AS difference FROM trips",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B34",
   "author_reading": "Compute the overall average from every nonmissing fare in trips, including trips from zone 0. Separately match pickup zones 1 through 77 to zones and compute each area's nonmissing fare count and average. Keep areas with at least 20 recorded fares and an unrounded average strictly above the overall average. Zero fares count. Use unrounded area averages for ordering and round displayed averages only.",
   "reading_sql": "WITH o AS (SELECT AVG(fare) AS overall FROM trips), a AS (SELECT pickup_zone_id, COUNT(fare) AS n, AVG(fare) AS avg_fare FROM trips WHERE pickup_zone_id <> 0 GROUP BY 1) SELECT a.pickup_zone_id, z.zone_name, n, ROUND(avg_fare, 2) AS area_avg, ROUND(o.overall, 2) AS overall_avg FROM a CROSS JOIN o JOIN zones z ON z.zone_id = a.pickup_zone_id WHERE n >= 20 AND avg_fare > o.overall ORDER BY avg_fare DESC, a.pickup_zone_id",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B35",
   "author_reading": "Keep trips with both tip and trip_total nonmissing and pickup identifiers 1 through 77, then match pickup areas to zones. Within each area, divide the sum of eligible tips by the sum of eligible trip totals and multiply by 100. This is a ratio of dollar totals, not an average of trip percentages. Include recorded zero and negative amounts but retain only areas with a positive denominator. Count eligible trips and round displayed percentages to two decimal places.",
   "reading_sql": "WITH a AS (SELECT pickup_zone_id, COUNT(*) AS n, SUM(tip) AS tips, SUM(trip_total) AS totals FROM trips WHERE tip IS NOT NULL AND trip_total IS NOT NULL AND pickup_zone_id <> 0 GROUP BY 1) SELECT a.pickup_zone_id, z.zone_name, n, ROUND(100.0 * tips / totals, 2) AS tip_pct FROM a JOIN zones z ON z.zone_id = a.pickup_zone_id WHERE totals > 0 ORDER BY 100.0 * tips / totals DESC, a.pickup_zone_id",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B36",
   "author_reading": "Use January rows in daily_trips and match pickup identifiers to zones. For each area, add nonmissing_fares across dates and separately add total_fare, treating a missing daily total as zero. Keep areas whose combined recorded-fare count is at least 100. Divide combined fare by combined recorded-fare count, rather than averaging daily averages. Sort before rounding and display averages to two decimal places.",
   "reading_sql": "WITH a AS (SELECT pickup_zone_id, SUM(nonmissing_fares) AS n, SUM(total_fare) AS f FROM daily_trips GROUP BY 1) SELECT a.pickup_zone_id, z.zone_name, n, ROUND(f / n, 2) AS avg_fare FROM a JOIN zones z ON z.zone_id = a.pickup_zone_id WHERE n >= 100 ORDER BY f / n DESC, a.pickup_zone_id",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B37",
   "author_reading": "Count trips by date in trips. Separately add daily_trips.trip_count across pickup zones for each date. Match these date-level results while preserving every date found in trips. Treat missing summary totals as zero. Return the two counts and their signed difference without rounding; do not join individual trip rows directly to summary rows.",
   "reading_sql": "WITH t AS (SELECT trip_date, COUNT(*) AS n FROM trips GROUP BY 1), s AS (SELECT trip_date, SUM(trip_count) AS n FROM daily_trips GROUP BY 1) SELECT t.trip_date, t.n AS detailed, COALESCE(s.n, 0) AS summarized, t.n - COALESCE(s.n, 0) AS difference FROM t LEFT JOIN s ON s.trip_date = t.trip_date ORDER BY 1",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B38",
   "author_reading": "Assign January trips to Monday-starting weeks and add nonmissing fares in each observed week, using zero if none are recorded. Independently total recorded fares across all January trips, using zero if none are recorded. Divide each week's revenue by the January total and multiply by 100. If that total is zero, return null percentages. Include the partial final week without adjustment, preserve unrounded revenue, and round percentages only.",
   "reading_sql": "WITH w AS (SELECT DATE_TRUNC('week', trip_date) AS week_monday, COALESCE(SUM(fare), 0) AS revenue FROM trips GROUP BY 1), o AS (SELECT SUM(fare) AS total FROM trips) SELECT week_monday, revenue, ROUND(100.0 * revenue / o.total, 2) AS pct FROM w CROSS JOIN o ORDER BY 1",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B39",
   "author_reading": "Independently count trips by pickup identifier and by dropoff identifier. Attach both sets of counts to directory zones 1 through 77, using zero for an absent count. Do not filter on the other endpoint and do not multiply rows by joining raw pickup and dropoff trips together. Keep areas whose pickup count exceeds their dropoff count. Return integer counts and the signed difference.",
   "reading_sql": "WITH p AS (SELECT pickup_zone_id AS zone_id, COUNT(*) AS n FROM trips GROUP BY 1), d AS (SELECT dropoff_zone_id AS zone_id, COUNT(*) AS n FROM trips GROUP BY 1) SELECT z.zone_id, z.zone_name, COALESCE(p.n, 0) AS pickups, COALESCE(d.n, 0) AS dropoffs, COALESCE(p.n, 0) - COALESCE(d.n, 0) AS difference FROM zones z LEFT JOIN p ON p.zone_id = z.zone_id LEFT JOIN d ON d.zone_id = z.zone_id WHERE z.zone_id <> 0 AND COALESCE(p.n, 0) > COALESCE(d.n, 0) ORDER BY difference DESC, z.zone_id",
   "reading_sql_is_key_sql": true,
   "agreed": true
  },
  {
   "id": "B40",
   "author_reading": "For each pickup identifier represented in January daily_trips, find its largest daily trip_count. Among that area's rows with this count, choose the earliest trip_date. Match the area identifier to zones for its name, including zone 0. Return exactly one row per matched area, with the chosen date and its integer trip count.",
   "reading_sql": "WITH c AS (SELECT pickup_zone_id, trip_date, SUM(trip_count) AS n FROM daily_trips GROUP BY 1, 2), m AS (SELECT pickup_zone_id, MAX(n) AS top FROM c GROUP BY 1), b AS (SELECT c.pickup_zone_id, MIN(c.trip_date) AS busiest, MAX(c.n) AS n FROM c JOIN m ON m.pickup_zone_id = c.pickup_zone_id AND c.n = m.top GROUP BY 1) SELECT b.pickup_zone_id, z.zone_name, b.busiest, b.n FROM b JOIN zones z ON z.zone_id = b.pickup_zone_id ORDER BY 1",
   "reading_sql_is_key_sql": true,
   "agreed": true
  }
 ]
}
