question_id
int64
0
499
db_id
stringclasses
11 values
question
stringlengths
54
1.57k
evidence
stringlengths
0
418
SQL
stringlengths
41
2.22k
difficulty
stringclasses
3 values
300
student_club
List the name of students that have attended more than 7 events.
SELECT T1.first_name, T1.last_name FROM member AS T1 INNER JOIN attendance AS T2 ON T1.member_id = T2.link_to_member GROUP BY T2.link_to_member HAVING COUNT(T2.link_to_event) > 7
moderate
301
student_club
Which members incurred at least one expense above the overall average expense cost? Give each member's first name, last name, and phone number as separate fields.
SELECT DISTINCT T3.first_name, T3.last_name, T3.phone FROM expense AS T1 INNER JOIN budget AS T2 ON T1.link_to_budget = T2.budget_id INNER JOIN member AS T3 ON T3.member_id = T1.link_to_member WHERE T1.cost > ( SELECT AVG(T1.cost) FROM expense AS T1 INNER JOIN budget AS T2 ON T1.link_to_budget = T2.budget_id INNER JOIN...
challenging
302
student_club
I'm putting together a review of last fall's activities and want to see how the Women's Soccer game compared to a typical event that semester. Please give me one row with: the number of students who attended the Women's Soccer event, the average number of students who attended events held in fall 2019 rounded to one de...
Women's Soccer is an event name; attendance at an event is the number of members who attended it.
WITH fall_events AS (SELECT e.event_id, (SELECT COUNT(*) FROM attendance AS a WHERE a.link_to_event = e.event_id) AS attendees FROM event AS e WHERE e.event_date >= '2019-09-01' AND e.event_date < '2019-12-01'), agg AS (SELECT ROUND(AVG(attendees), 1) AS avg_att FROM fall_events), soccer AS (SELECT COUNT(*) AS head_cou...
challenging
303
student_club
I'm reviewing our roster against the catalog and want to see how much of the College of Humanities and Social Sciences' coverage our members actually hold, department by department. For each department in that college, give me: the department's name, the majors it offers, the majors held by at least one of our members,...
College of Humanities and Social Sciences: one of the colleges that houses departments offering majors.
SELECT m.department, COUNT(DISTINCT m.major_id) AS majors_offered, COUNT(DISTINCT mem.link_to_major) AS majors_held, ROUND(1.0 * COUNT(DISTINCT mem.member_id) / COUNT(DISTINCT m.major_id), 2) AS avg_members_per_major FROM major m LEFT JOIN member mem ON mem.link_to_major = m.major_id WHERE m.college = 'College of Human...
challenging
304
student_club
I'm putting together our yearly report and need a breakdown of our 2019 events by event type. For each type of event we held in 2019, please give me: the event type, how many members attended that type's events during 2019, and the total amount budgeted for that type's events in dollars. A few notes: 2019 means the cal...
SELECT e.type AS event_type, (SELECT COUNT(DISTINCT a.link_to_member) FROM attendance a JOIN event e2 ON e2.event_id = a.link_to_event WHERE e2.type = e.type AND SUBSTR(e2.event_date, 1, 4) = '2019') AS members_who_attended, CAST(COALESCE((SELECT SUM(b.amount) FROM budget b JOIN event e3 ON e3.event_id = b.link_to_even...
challenging
305
student_club
I'm putting together a financial overview for the college that houses the Electrical and Computer Engineering Department. For each department of that college, can you tell me the total dues the club actually received from that department's enrolled members who took part in the club's events, in dollars? Please include ...
'Dues' is the income source label for membership dues a member pays to the club; 'Member' is the club position of an enrolled member, as opposed to officer or inactive positions.
SELECT m.department, COALESCE(SUM(i.amount), 0) AS total_dues_received FROM major AS m LEFT JOIN member AS mb ON mb.link_to_major = m.major_id AND mb.position = 'Member' LEFT JOIN income AS i ON i.link_to_member = mb.member_id AND i.source = 'Dues' AND EXISTS (SELECT 1 FROM attendance AS a WHERE a.link_to_member = mb.m...
challenging
306
student_club
For the mid-year budget review: I need to see, for each member who had to spend more than fifty dollars on an expense, how much room was still left in the budget lines those purchases were charged against. Please give me, per member, their first name, last name, and the total amount left across those budget lines in do...
Spending more than fifty dollars on an expense means the expense's dollar cost is over 50. The amount left in a budget line is the amount budgeted for that line minus the amount spent against it.
SELECT m.first_name, m.last_name, ROUND(SUM(b.remaining), 2) AS remaining_total FROM member AS m JOIN (SELECT DISTINCT link_to_member, link_to_budget FROM expense WHERE cost > 50) AS e ON e.link_to_member = m.member_id JOIN budget AS b ON b.budget_id = e.link_to_budget GROUP BY m.member_id, m.first_name, m.last_name OR...
challenging
307
student_club
I'm putting together our year-end budget summary. How much did we collect in membership dues, in total dollars, from the students who attended the Football game? Membership dues are the payments recorded under the source 'Dues'.
membership dues: payments recorded under the source 'Dues'
SELECT SUM(i.amount) AS total_dues FROM income AS i WHERE i.source = 'Dues' AND i.link_to_member IN (SELECT a.link_to_member FROM attendance AS a INNER JOIN event AS e ON a.link_to_event = e.event_id WHERE e.event_name = 'Football game')
challenging
308
student_club
How many majors offered by the college that offers Tyler Hewitt's major currently have no enrolled members in the club? Count every major that college offers, by major name.
Enrolled members are the people recorded in the club's membership list.
SELECT COUNT(*) AS num_majors_without_members FROM major AS m WHERE m.college = (SELECT T2.college FROM member AS T1 INNER JOIN major AS T2 ON T1.link_to_major = T2.major_id WHERE T1.first_name = 'Tyler' AND T1.last_name = 'Hewitt') AND NOT EXISTS (SELECT 1 FROM member AS mm WHERE mm.link_to_major = m.major_id)
challenging
309
student_club
For our end-of-year report, I need one figure: the average number of members who attended each event that carried a budget line for advertising, covering every such event across the club's records regardless of when it took place. Please give it as a single number rounded to two decimal places.
A budget line for advertising means a budget entry whose category is advertising.
WITH att AS (SELECT link_to_event, COUNT(DISTINCT link_to_member) AS members FROM attendance GROUP BY link_to_event) SELECT ROUND(AVG(COALESCE(att.members, 0)), 2) AS average_attendance FROM event AS T1 INNER JOIN budget AS T2 ON T2.link_to_event = T1.event_id AND T2.category = 'Advertisement' LEFT JOIN att ON att.link...
challenging
310
student_club
For every budget review event the club has held, can you give me the event name, its location, and the number of members who attended? I need this for the year-end report.
'Budget' is the club's event type for its budget review events, such as the Fall Budget Review and the Spring Budget Review.
SELECT e.event_name, e.location, COUNT(a.link_to_member) AS attended FROM event e LEFT JOIN attendance a ON e.event_id = a.link_to_event WHERE e.type = 'Budget' GROUP BY e.event_id, e.event_name, e.location
challenging
311
student_club
I'm planning study-partner pairings around our biggest social-attendance event. Can you tell me which academic majors were most represented among the members who attended the football game? For each major, give me the major name and the number of attendees in that major. If several majors tie for the highest attendee c...
Football game: the event named 'Football game'
WITH cnt AS (SELECT mj.major_name AS major_name, COUNT(DISTINCT m.member_id) AS attendees FROM event e JOIN attendance a ON a.link_to_event = e.event_id JOIN member m ON m.member_id = a.link_to_member JOIN major mj ON mj.major_id = m.link_to_major WHERE e.event_name = 'Football game' GROUP BY mj.major_id, mj.major_name...
challenging
312
student_club
I want to gauge how much of the university's range of academic programs our club is failing to reach. Out of every major offered by the university - including majors where we have no members - what percentage have no club member studying them? Please give me just that single percentage, between 0 and 100, rounded to tw...
Major: an academic program offered by the university, as listed in the club's records of majors.
SELECT ROUND(CAST((SELECT COUNT(*) FROM major AS m WHERE NOT EXISTS (SELECT 1 FROM member AS mem WHERE mem.link_to_major = m.major_id)) AS REAL) * 100 / (SELECT COUNT(*) FROM major), 2) AS percentage
challenging
313
student_club
Our officer team wants to settle a debate about whether we pull more weight than the rest of the club, so we need the attendance numbers before the next meeting. Could you tell us two things: the average number of events attended per officer, and the average number of events attended per other student, each rounded to ...
WITH t AS (SELECT m.member_id, m.position, COUNT(a.link_to_event) AS cnt FROM member m LEFT JOIN attendance a ON a.link_to_member = m.member_id GROUP BY m.member_id, m.position) SELECT ROUND(AVG(CASE WHEN t.position IN ('President','Vice President','Secretary','Treasurer') THEN t.cnt END), 2) AS officer_avg, ROUND(AVG(...
challenging
314
student_club
I'm finalizing the semester wrap-up report and need one number: how many different kinds of things the club bought for events that went over budget this semester. A few things to keep in mind: an event counts as over budget if, in at least one of its budgeted categories, we spent more than we budgeted for that category...
went over budget: a budgeted category of the event ended with more spent than was budgeted for it, i.e. the amount budgeted minus the amount spent is below zero; kind of thing: a type of item bought, like water, pizza or posters
WITH RECURSIVE over_budget_events AS (SELECT DISTINCT link_to_event FROM budget WHERE amount - spent < 0), purchases AS (SELECT ex.expense_description AS d FROM expense ex JOIN budget b ON ex.link_to_budget = b.budget_id WHERE b.link_to_event IN (SELECT link_to_event FROM over_budget_events)), items(item, rest) AS (SEL...
challenging
315
student_club
For every event in our records that had at least one attendee, I need the amount spent per attendee on bottled drinking water, in dollars and cents rounded to two decimals. Give me one row per event with the event name and that amount; if an attended event had no water purchases, show 0.00, and if two events share a na...
water: bottled drinking water bought for attendees
WITH water AS (SELECT b.link_to_event AS event_id, SUM(e.cost) AS total_cost FROM expense e JOIN budget b ON e.link_to_budget = b.budget_id WHERE e.expense_description LIKE '%water%' GROUP BY b.link_to_event), att AS (SELECT link_to_event AS event_id, COUNT(*) AS attendees FROM attendance GROUP BY link_to_event) SELECT...
challenging
316
student_club
For my report on the club's academic makeup, could you tell me how many members on the club roster major in a department of the College of Humanities and Social Sciences, and how many members do not? The two counts together should cover every member on the roster, with each member counted in exactly one of the two grou...
The College of Humanities and Social Sciences is a college made up of certain departments; membership in the college is determined by which department offers a member's major.
WITH flag AS (SELECT m.member_id, CASE WHEN b.college = 'College of Humanities and Social Sciences' THEN 1 ELSE 0 END AS in_college FROM member m LEFT JOIN major b ON m.link_to_major = b.major_id) SELECT SUM(in_college) AS members_in_college, COUNT(*) - SUM(in_college) AS members_not_in_college FROM flag
challenging
317
student_club
For our snack budget planning: among the events that spent money on chips, which event has the highest budget amount? By budget amount I mean a single budget line, not a total across lines - compare events by their largest single budgeted line. If several events tie on that largest line, list all of their names. Please...
WITH chip_events AS (SELECT DISTINCT b.link_to_event AS event_id FROM budget AS b INNER JOIN expense AS x ON x.link_to_budget = b.budget_id WHERE x.expense_description LIKE '%chips%') SELECT e.event_name FROM event AS e INNER JOIN budget AS b ON b.link_to_event = e.event_id WHERE e.event_id IN (SELECT event_id FROM chi...
challenging
318
student_club
What is the date of the Vice President's most recent expense on record, and what is the total cost of all expenses incurred on that date? Consider all expenses on record with no earlier cut-off, and give the total exactly as it appears in the records, without rounding.
Vice President is a position of the Student Club.
SELECT e.expense_date, SUM(e.cost) AS total_cost FROM expense e JOIN member m ON m.member_id = e.link_to_member WHERE m.position = 'Vice President' AND e.expense_date = (SELECT MAX(e2.expense_date) FROM expense e2 JOIN member m2 ON m2.member_id = e2.link_to_member WHERE m2.position = 'Vice President') GROUP BY e.expens...
challenging
319
student_club
I'm reviewing member engagement for our club's events in MU 215. Can you give me, for each event category of events held at MU 215, the number of club members who attended those events? Please count events regardless of their status (planning, open, or closed), and make sure every category that had events at MU 215 sho...
MU 215: the room name as the event location.
SELECT e.type AS event_category, COUNT(DISTINCT a.link_to_member) AS attended_members FROM event e LEFT JOIN attendance a ON a.link_to_event = e.event_id WHERE e.location = 'MU 215' GROUP BY e.type
challenging
320
student_club
I'm putting together a recruitment report for the colleges and want to know which parts of the university our club's membership actually draws from. For every person on the roster-regardless of their position in the club-look at their major, and the college that houses the department offering that major. Which college ...
Major: a field of study offered by a department housed in a college.
WITH cnt AS (SELECT mj.college AS college, COUNT(DISTINCT mj.major_id) AS majors FROM member m JOIN major mj ON mj.major_id = m.link_to_major GROUP BY mj.college) SELECT college, majors FROM cnt WHERE majors = (SELECT MAX(majors) FROM cnt) ORDER BY college
challenging
321
student_club
I want to review what the money actually went on for the well-funded events, by venue. For events that had a budget line of more than forty dollars, how many different things were bought for them at each location? Please give me, for each location, the location of the event and the number of different things bought for...
WITH RECURSIVE split(item, rest, loc) AS (SELECT '', x.expense_description || ',', e.location FROM expense x JOIN budget b ON b.budget_id = x.link_to_budget JOIN event e ON e.event_id = b.link_to_event WHERE b.amount > 40 UNION ALL SELECT trim(substr(rest, 1, instr(rest, ',') - 1)), substr(rest, instr(rest, ',') + 1), ...
challenging
322
student_club
I'm reconciling what we budgeted for September events against what we actually spent. Can you give me the total amount budgeted for the September 2019 events that served pizza? By September 2019 I mean events dated September 1 through September 30, 2019. An event counts as having served pizza if pizza was among the exp...
A pizza expense means an expense whose description is Pizza.
WITH pizza_events AS (SELECT DISTINCT b.link_to_event AS event_id FROM expense e JOIN budget b ON e.link_to_budget = b.budget_id WHERE e.expense_description = 'Pizza'), sept_events AS (SELECT event_id FROM event WHERE event_date >= '2019-09-01' AND event_date < '2019-10-01') SELECT ROUND(SUM(b.amount), 2) AS total_budg...
challenging
323
student_club
Hi - I need one overall figure for the budget next year: what's the average total amount we've actually spent per event, counting all budget categories, across every event we've ever recorded? Please give me the average in dollars, rounded to two decimal places, with no date restriction.
WITH per_event AS (SELECT e.event_id, COALESCE(SUM(b.spent), 0) AS total_spent FROM event e LEFT JOIN budget b ON b.link_to_event = e.event_id GROUP BY e.event_id) SELECT ROUND(AVG(total_spent), 2) AS average_total_spent_per_event FROM per_event
challenging
324
student_club
Among our closed events that stayed within budget (total spending not exceeding total budget), which one had the most purchases? Please give me just that event's name. Consider every closed event that didn't go over budget, including events with no purchases at all. If two events tie for the most purchases, report only...
A purchase is a single item recorded on an expense record; one expense record may list several items. Total budget is the sum of budgeted amounts across all budget lines of the event; total spending is the sum of spent amounts across all budget lines of the event.
WITH budget_totals AS (SELECT link_to_event, SUM(spent) AS total_spending, SUM(amount) AS total_budget FROM budget GROUP BY link_to_event), items AS (SELECT b.link_to_event, SUM(LENGTH(x.expense_description) - LENGTH(REPLACE(x.expense_description, ',', '')) + 1) AS purchases FROM expense x JOIN budget b ON b.budget_id ...
challenging
325
student_club
For our year-end review, I want to know which event formats bring in the most people. Looking at our whole club year (every event from September 2019 through May 2020), which event type was attended by the most members, and how many members attended that type's events? If several event types tie for the most, list ever...
By "attended" I mean a member coming to an event; event type is the kind of event, e.g. Meeting, Social, Game, Election, Community Service.
WITH member_counts AS (SELECT e.type AS event_type, COUNT(DISTINCT a.link_to_member) AS members FROM event e LEFT JOIN attendance a ON a.link_to_event = e.event_id GROUP BY e.type) SELECT event_type, members FROM member_counts WHERE members = (SELECT MAX(members) FROM member_counts) ORDER BY event_type
challenging
326
student_club
I'm putting together next semester's purchasing plan and want to know which food and drink item the club buys most often. Among purchases made under the food budget only, which single item appears on the most purchase records, and how many purchase records mention it? If two items are tied, go with the one whose name c...
A purchase record is an entry in the club's expense records for money spent on a purchase.
WITH RECURSIVE items(expense_id, item, rest) AS (SELECT e.expense_id, '', e.expense_description || ',' FROM expense e JOIN budget b ON e.link_to_budget = b.budget_id WHERE b.category = 'Food' UNION ALL SELECT expense_id, trim(substr(rest, 1, instr(rest, ',') - 1)), substr(rest, instr(rest, ',') + 1) FROM items WHERE re...
challenging
327
student_club
I'm wrapping up the October Meeting and need the final numbers broken down by what we actually bought, not just by budget category. For every item bought with approved money for the October Meeting, can you give me: the item's name, the budget category of the purchase that included the item, and the total cost in dolla...
An item is a single thing bought with club money, such as water, pizza or posters. A purchase is an expense recorded for the event.
WITH RECURSIVE split AS (SELECT link_to_budget AS bid, cost, '' AS item, expense_description || ',' AS rest FROM expense WHERE approved = 'true' UNION ALL SELECT bid, cost, trim(substr(rest, 1, instr(rest, ',') - 1)), substr(rest, instr(rest, ',') + 1) FROM split WHERE rest <> '') SELECT s.item AS item, b.category AS c...
challenging
328
student_club
For every event in the club's records, can you give me the event name, event date, total amount budgeted for the event, and the number of members who attended it? Please sort the list by event name, then by event date, both in ascending order.
SELECT e.event_name, e.event_date, COALESCE(b.total_budgeted_amount, 0) AS total_budgeted_amount, COALESCE(a.attendee_count, 0) AS attendee_count FROM event AS e LEFT JOIN (SELECT link_to_event, SUM(amount) AS total_budgeted_amount FROM budget GROUP BY link_to_event) AS b ON b.link_to_event = e.event_id LEFT JOIN (SELE...
challenging
329
student_club
I'm preparing the year-end audit of club spending. For each item Sacha Harrison bought with club money, I need the item name and how many times she bought it. Can you give me that list?
By "item" I mean an individual thing named in a record of what money was spent for.
WITH RECURSIVE split(rest, item) AS (SELECT expense_description || ',', '' FROM expense WHERE link_to_member = (SELECT member_id FROM member WHERE first_name = 'Sacha' AND last_name = 'Harrison') UNION ALL SELECT substr(rest, instr(rest, ',') + 1), trim(substr(rest, 1, instr(rest, ',') - 1)) FROM split WHERE rest <> ''...
challenging
330
student_club
I'm putting together the end-of-term spending review. Who bought the most different kinds of items in October or November 2019? Please give me that member's full name, how many different kinds of items they bought in those two months, and their total spending in dollars over the same period. If two members tie for the ...
An item is one of the individual things a purchase covered, such as a pizza or a bottle of water.
WITH RECURSIVE split AS (SELECT link_to_member, expense_description AS rest FROM expense WHERE expense_date BETWEEN '2019-10-01' AND '2019-11-30' UNION ALL SELECT link_to_member, SUBSTR(rest, INSTR(rest || ',', ',') + 1) FROM split WHERE rest <> ''), items AS (SELECT link_to_member, TRIM(SUBSTR(rest, 1, INSTR(rest || '...
challenging
331
student_club
For our department report, I need to know how many different fields of study our club members from the Political Science Department represent. Only count members of the Political Science Department - members from other departments don't count. Just give me the number of different majors studied by those members.
A major is a field of study offered by a department.
SELECT COUNT(DISTINCT T2.major_id) AS different_majors FROM member AS T1 INNER JOIN major AS T2 ON T1.link_to_major = T2.major_id WHERE T2.department = 'Political Science Department'
challenging
332
superhero
Among Marvel Comics superheroes with a known eye colour, rank the eye colours by number of superheroes. Give each colour, its hero count, and its rank, most common first; break display-order ties alphabetically.
WITH colour_counts AS (SELECT c.colour AS eye_colour, COUNT(*) AS hero_count FROM superhero AS s JOIN colour AS c ON c.id = s.eye_colour_id JOIN publisher AS p ON p.id = s.publisher_id WHERE p.publisher_name = 'Marvel Comics' AND c.colour <> 'No Colour' GROUP BY c.colour) SELECT eye_colour, hero_count, RANK() OVER (ORD...
moderate
333
superhero
List the superheroes from Marvel Comics who have the super power of 'Super Strength'.
SELECT superhero_name FROM superhero AS T1 WHERE EXISTS (SELECT 1 FROM hero_power AS T2 INNER JOIN superpower AS T3 ON T2.power_id = T3.id WHERE T3.power_name = 'Super Strength' AND T1.id = T2.hero_id)AND EXISTS (SELECT 1 FROM publisher AS T4 WHERE T4.publisher_name = 'Marvel Comics' AND T1.publisher_id = T4.id)
challenging
334
superhero
What percentage of all superheroes have Neutral alignment, and how many of those Neutral superheroes were published by Marvel Comics? Round the percentage to two decimals.
SELECT ROUND(100.0 * SUM(CASE WHEN a.alignment = 'Neutral' THEN 1 ELSE 0 END) / NULLIF(COUNT(*), 0), 2), SUM(CASE WHEN a.alignment = 'Neutral' AND p.publisher_name = 'Marvel Comics' THEN 1 ELSE 0 END) FROM superhero AS s LEFT JOIN alignment AS a ON a.id = s.alignment_id LEFT JOIN publisher AS p ON p.id = s.publisher_id
challenging
335
superhero
Between Marvel Comics and DC Comics, which publisher has more superheroes, and by how many?
WITH counts AS ( SELECT SUM(CASE WHEN p.publisher_name = 'Marvel Comics' THEN 1 ELSE 0 END) AS marvel_count, SUM(CASE WHEN p.publisher_name = 'DC Comics' THEN 1 ELSE 0 END) AS dc_count FROM superhero AS s JOIN publisher AS p ON p.id = s.publisher_id ) SELECT CASE WHEN marvel_count > dc_count THEN 'Marvel Comics' WHEN d...
challenging
336
superhero
Among superheroes from 170 through 190 cm tall whose recorded eye-colour category is unknown, list their names.
SELECT DISTINCT T1.superhero_name FROM superhero AS T1 INNER JOIN colour AS T2 ON T1.eye_colour_id = T2.id WHERE T1.height_cm BETWEEN 170 AND 190 AND T2.colour = 'No Colour'
moderate
337
superhero
Among all superheroes with recorded height from 150 through 180 cm, what percentage were published by Marvel Comics? Round to two decimals.
SELECT ROUND(100.0 * SUM(CASE WHEN p.publisher_name = 'Marvel Comics' THEN 1 ELSE 0 END) / NULLIF(COUNT(*), 0), 2) FROM superhero AS s LEFT JOIN publisher AS p ON p.id = s.publisher_id WHERE s.height_cm BETWEEN 150 AND 180
challenging
338
superhero
What known full names belong to superheroes tied for the highest strength attribute value?
SELECT DISTINCT s.full_name FROM superhero AS s JOIN hero_attribute AS ha ON ha.hero_id = s.id JOIN attribute AS a ON a.id = ha.attribute_id WHERE a.attribute_name = 'Strength' AND ha.attribute_value = ( SELECT MAX(ha2.attribute_value) FROM hero_attribute AS ha2 JOIN attribute AS a2 ON a2.id = ha2.attribute_id WHERE a2...
moderate
339
superhero
List superheroes whose known eye, hair and skin colours are all the same, along with any recorded publisher name.
SELECT s.superhero_name, p.publisher_name FROM superhero AS s LEFT JOIN publisher AS p ON p.id = s.publisher_id JOIN colour AS c ON c.id = s.eye_colour_id WHERE s.eye_colour_id = s.hair_colour_id AND s.eye_colour_id = s.skin_colour_id AND c.colour <> 'No Colour'
challenging
340
superhero
Among all female superheroes, what percentage have blue skin? Round to two decimals.
SELECT ROUND(100.0 * SUM(CASE WHEN co.colour = 'Blue' THEN 1 ELSE 0 END) / NULLIF(COUNT(*), 0), 2) FROM superhero AS s JOIN gender AS g ON g.id = s.gender_id LEFT JOIN colour AS co ON co.id = s.skin_colour_id WHERE g.gender = 'Female'
challenging
341
superhero
Among all female superheroes, what percentage were published by Marvel Comics? Round to two decimal places.
SELECT ROUND(100.0 * SUM(CASE WHEN p.publisher_name = 'Marvel Comics' THEN 1 ELSE 0 END) / NULLIF(COUNT(*), 0), 2) FROM superhero AS s JOIN gender AS g ON s.gender_id = g.id LEFT JOIN publisher AS p ON s.publisher_id = p.id WHERE g.gender = 'Female'
challenging
342
superhero
Which publisher has more superheroes, DC Comics or Marvel Comics, and by how many? Return Tie if their counts are equal.
WITH counts AS (SELECT SUM(CASE WHEN p.publisher_name = 'DC Comics' THEN 1 ELSE 0 END) AS dc, SUM(CASE WHEN p.publisher_name = 'Marvel Comics' THEN 1 ELSE 0 END) AS marvel FROM superhero AS s JOIN publisher AS p ON p.id = s.publisher_id) SELECT CASE WHEN dc > marvel THEN 'DC Comics' WHEN marvel > dc THEN 'Marvel Comics...
challenging
343
superhero
I'm comparing Marvel and DC rosters and want to quantify how tall Marvel's roster is for characters whose abilities DC cannot match. What is the average height, in centimetres, of Marvel Comics characters who have at least one power that no DC Comics character has? Only characters with a measured height count.
A "power" is any single ability listed for a character in the database.
SELECT AVG(s.height_cm) AS average_height_cm FROM superhero AS s JOIN publisher AS p ON s.publisher_id = p.id WHERE p.publisher_name = 'Marvel Comics' AND s.height_cm > 0 AND EXISTS (SELECT 1 FROM hero_power AS hp WHERE hp.hero_id = s.id AND NOT EXISTS (SELECT 1 FROM hero_power AS hp2 JOIN superhero AS s2 ON s2.id = hp...
challenging
344
superhero
For a segment on strength heroes, I want to know how many superpowers are held only by heroes who have Super Strength. A power counts as held only if at least one hero who has Super Strength holds it, and Super Strength itself should be included if it meets that condition. Just give me the count.
Super Strength is a super power name.
WITH strength_heroes AS (SELECT hp.hero_id FROM hero_power AS hp INNER JOIN superpower AS sp ON hp.power_id = sp.id WHERE sp.power_name = 'Super Strength') SELECT COUNT(*) AS power_count FROM superpower AS s WHERE EXISTS (SELECT 1 FROM hero_power AS hp WHERE hp.power_id = s.id AND hp.hero_id IN (SELECT hero_id FROM str...
challenging
345
superhero
I'm setting a typical weight for a green-skinned creature class. Can you tell me the average weight in kg of the heroes with green skin? Count only heroes whose weight is known, and give me one number rounded to one decimal place.
Green skin means the hero's skin colour is green.
SELECT ROUND(AVG(T1.weight_kg), 1) AS average_weight_kg FROM superhero AS T1 INNER JOIN colour AS T2 ON T1.skin_colour_id = T2.id WHERE T2.colour = 'Green' AND T1.weight_kg > 0
challenging
346
superhero
I'm writing an article about heroes who fall outside the classic good-versus-evil divide. How many superheroes in the database have an alignment that is neither good nor bad? Please give me just that count. Note that this should cover all superheroes in the database.
good: a superhero whose alignment is Good; bad: a superhero whose alignment is Bad; alignment: the moral category assigned to a superhero
SELECT COUNT(*) AS neither_good_nor_bad FROM superhero AS s LEFT JOIN alignment AS a ON s.alignment_id = a.id WHERE a.alignment IS NULL OR a.alignment NOT IN ('Good', 'Bad')
challenging
347
superhero
I'm building a fact box on Marvel heroes' civilian identities. Among Marvel Comics superheroes whose full name (their civilian identity, like 'Richard Milhouse Jones') is known, which superpower is the most common, and how many of those heroes have it? If several superpowers tie for most common, list all of them with t...
WITH pc AS (SELECT sp.power_name, COUNT(DISTINCT hp.hero_id) AS hero_count FROM hero_power hp JOIN superpower sp ON hp.power_id = sp.id JOIN superhero s ON hp.hero_id = s.id JOIN publisher p ON s.publisher_id = p.id WHERE p.publisher_name = 'Marvel Comics' AND s.full_name IS NOT NULL AND s.full_name <> '-' GROUP BY sp....
challenging
348
superhero
I want to profile the cohort of heroes whose Intelligence score matches Abomination's Intelligence score. What is their average measured weight in kg? Please round the average to two decimals.
Intelligence is one of the six attribute scores a hero has (Intelligence, Strength, Speed, Durability, Power, Combat)
SELECT ROUND(AVG(CASE WHEN s.weight_kg > 0 THEN s.weight_kg END), 2) AS average_weight_kg FROM superhero s JOIN hero_attribute ha ON ha.hero_id = s.id JOIN attribute a ON a.id = ha.attribute_id WHERE a.attribute_name = 'Intelligence' AND ha.attribute_value = (SELECT abom_ha.attribute_value FROM superhero abom JOIN hero...
challenging
349
superhero
I'm putting together a trivia page profiling blue-haired heroes by their abilities. For each gender, male and female, how many blue-haired superheroes have at least ten listed powers? I need the count for both groups, and by 'at least ten' I mean ten or more.
Listed powers: the superpowers recorded for a hero.
SELECT g.gender AS gender, COUNT(s.id) AS superhero_count FROM gender g LEFT JOIN superhero s ON s.gender_id = g.id AND s.hair_colour_id = (SELECT id FROM colour WHERE colour = 'Blue') AND (SELECT COUNT(*) FROM hero_power hp WHERE hp.hero_id = s.id) >= 10 WHERE g.gender IN ('Male','Female') GROUP BY g.gender ORDER BY g...
challenging
350
superhero
I'm putting together a comparison of the heaviest brick-strength characters. What is the average weight, in kilograms, of all superheroes whose Strength score equals the Hulk's? I just need a single integer rounded to the nearest kilogram. Include every superhero in the database, no restrictions on publisher or alignme...
Strength is one of the six measured hero attributes, each scored on a 1-100 scale; the Hulk is the superhero named 'Hulk'; weight is the superhero's weight in kilograms.
SELECT CAST(ROUND(AVG(s.weight_kg)) AS INTEGER) AS average_weight_kg FROM superhero s INNER JOIN hero_attribute ha ON ha.hero_id = s.id INNER JOIN attribute a ON a.id = ha.attribute_id WHERE a.attribute_name = 'Strength' AND ha.attribute_value = (SELECT ha2.attribute_value FROM superhero s2 INNER JOIN hero_attribute ha...
challenging
351
superhero
For my 'giants of the genre' feature, I want to headline how varied the abilities of the tallest heroes are. How many different superpowers appear among the ten tallest superheroes? Rank heroes by height and take the top ten; if several heroes tie at the tenth-tallest height, include all of them. A hero counts among th...
superpower = an ability such as Agility or Accelerated Healing, as named in the superpower list
WITH top10 AS (SELECT id FROM superhero ORDER BY height_cm DESC LIMIT 10) SELECT COUNT(DISTINCT T3.power_name) AS superpowers FROM top10 JOIN hero_power T2 ON top10.id = T2.hero_id JOIN superpower T3 ON T2.power_id = T3.id
challenging
352
superhero
How many characters published by A-Bomb's publisher have no race listed? I just need a single count. (By A-Bomb's publisher, I mean the publisher that publishes the character A-Bomb.)
race: the character's race or group, e.g. Human, Alien, Mutant
SELECT COUNT(*) AS character_count FROM superhero WHERE publisher_id = (SELECT publisher_id FROM superhero WHERE superhero_name = 'A-Bomb') AND (race_id IS NULL OR race_id = (SELECT id FROM race WHERE race = '-'))
challenging
353
superhero
Hey, following up on my count of the God / Eternal heroes – among those who are male, what's the average number of superpowers per hero? Just give me the average rounded to two decimal places.
A superpower is any power linked to a hero.
WITH power_counts AS (SELECT s.id, (SELECT COUNT(*) FROM hero_power AS hp WHERE hp.hero_id = s.id) AS power_count FROM superhero AS s INNER JOIN race AS r ON s.race_id = r.id INNER JOIN gender AS g ON s.gender_id = g.id WHERE r.race = 'God / Eternal' AND g.gender = 'Male') SELECT ROUND(AVG(power_count), 2) AS average_s...
challenging
354
superhero
For my cryokinesis page, I want to know how broad the power portfolios are around ice-powered heroes. Consider all heroes who share at least one superpower with a cryokinesis holder - including the cryokinesis holders themselves, since they share cryokinesis with each other. What is the average number of superpowers th...
Cryokinesis is the superpower to generate and control ice.
WITH sharers AS (SELECT DISTINCT hp2.hero_id FROM hero_power hp1 JOIN hero_power hp2 ON hp2.power_id = hp1.power_id WHERE hp1.hero_id IN (SELECT hero_id FROM hero_power WHERE power_id = (SELECT id FROM superpower WHERE power_name = 'Cryokinesis'))), counts AS (SELECT hero_id, COUNT(*) AS cnt FROM hero_power WHERE hero_...
challenging
355
superhero
What is the average weight in kilograms of the DC Comics heroes whose eye colour is also shared by at least one Marvel Comics hero? Leave out any heroes whose weight is unknown, round the result to the nearest kilogram, and treat 'No Colour' as an eye colour like any other when matching between publishers. I just want ...
SELECT ROUND(AVG(CASE WHEN s.weight_kg > 0 THEN s.weight_kg END)) AS average_weight_kg FROM superhero AS s JOIN publisher AS p ON s.publisher_id = p.id WHERE p.publisher_name = 'DC Comics' AND s.eye_colour_id IN (SELECT s2.eye_colour_id FROM superhero AS s2 JOIN publisher AS p2 ON s2.publisher_id = p2.id WHERE p2.publi...
challenging
356
superhero
I'm researching heroes like A-Bomb. What is the average height in centimetres of the superheroes in A-Bomb's group? Please give me just that single number, rounded to one decimal place. Note that A-Bomb itself belongs to its group and should be included, and only heroes whose height is actually on record should count t...
In this request, "group" refers to race.
SELECT ROUND(AVG(CASE WHEN height_cm > 0 THEN height_cm END), 1) AS average_height_cm FROM superhero WHERE race_id = (SELECT race_id FROM superhero WHERE superhero_name = 'A-Bomb')
challenging
357
superhero
What is the average weight, in kg, of the heroes who belong to races in which no hero is female? Heroes whose weight is not recorded should not count toward the average. I just need that single value.
female: the hero's gender is female
SELECT AVG(T1.weight_kg) AS average_weight_kg FROM superhero AS T1 INNER JOIN race AS T2 ON T1.race_id = T2.id WHERE T1.weight_kg > 0 AND NOT EXISTS (SELECT 1 FROM superhero AS T3 INNER JOIN gender AS T4 ON T3.gender_id = T4.id WHERE T3.race_id = T2.id AND T4.gender = 'Female')
challenging
358
superhero
I'm writing a piece about which real publishing companies have put out very tall heroes. How many publishers in the database have released at least one hero taller than 200 cm? Note that taller than 200 cm means strictly more than 200 cm, and it counts if even one of their heroes is that tall. I just need the number of...
A hero's publisher being 'released' means the publisher the hero is attributed to in the database.
SELECT COUNT(DISTINCT T1.publisher_id) AS publisher_count FROM superhero AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.id WHERE T1.height_cm > 200 AND T2.publisher_name <> ''
challenging
359
superhero
For a licensing survey of non-DC heroic characters, I need a single total count of superheroes whose alignment is Good and who are not published by DC Comics. Just that one number, please.
Good means the hero's alignment is Good; DC Comics means the publisher named DC Comics.
SELECT COUNT(*) AS hero_count FROM superhero AS T1 INNER JOIN alignment AS T2 ON T1.alignment_id = T2.id WHERE T2.alignment = 'Good' AND NOT EXISTS (SELECT 1 FROM publisher AS T3 WHERE T3.id = T1.publisher_id AND T3.publisher_name = 'DC Comics')
challenging
360
superhero
I'm comparing superhero body weights to typical human weights for an article. What is the average weight in kilograms of superheroes published by DC Comics, rounded to one decimal place, and how many DC Comics superheroes is that average based on? Only superheroes with a known weight should count toward the average, so...
SELECT ROUND(AVG(s.weight_kg), 1) AS avg_weight_kg, COUNT(*) AS hero_count FROM superhero s JOIN publisher p ON s.publisher_id = p.id WHERE p.publisher_name = 'DC Comics' AND s.weight_kg > 0
challenging
361
superhero
How many heroes published by Blackwulf's publisher have an eye colour that at least one hero from a different publisher also has? By "that publisher's heroes" I mean all of its heroes, not just Blackwulf. A different publisher means any other publisher, and heroes with no publisher listed shouldn't count as coming from...
Eye colour: the colour of a hero's eyes as catalogued for that hero.
WITH blk AS (SELECT publisher_id AS pid FROM superhero WHERE superhero_name = 'Blackwulf') SELECT COUNT(*) AS hero_count FROM superhero m WHERE m.publisher_id = (SELECT pid FROM blk) AND m.eye_colour_id IN (SELECT d.eye_colour_id FROM superhero d WHERE d.publisher_id IS NOT NULL AND d.publisher_id <> (SELECT pid FROM b...
challenging
362
superhero
Which race is the most common among the superheroes published by the same publisher as the superhero whose full name is Charles Chandler? I'd like, for that publisher's superheroes only, the name of the most common race and the count of that publisher's superheroes of that race. Ignore any superhero with no race record...
Race: the superhero's species or type, e.g. Human, Mutant, Alien.
WITH counts AS (SELECT r.race AS race, COUNT(*) AS hero_count FROM superhero AS s INNER JOIN race AS r ON s.race_id = r.id WHERE s.publisher_id = (SELECT publisher_id FROM superhero WHERE full_name = 'Charles Chandler') AND r.race <> '-' GROUP BY r.id, r.race) SELECT race, hero_count FROM counts WHERE hero_count = (SEL...
challenging
363
superhero
What is the average weight in kg of the Female heroes in the database? Round it to two decimal places, and skip any heroes whose weight is unknown. I just need that single number.
kg: kilograms
SELECT ROUND(AVG(weight_kg), 2) AS average_weight_kg FROM superhero WHERE gender_id = (SELECT id FROM gender WHERE gender = 'Female') AND weight_kg > 0
challenging
364
superhero
I'm writing a power-profile feature on heroes with super speed or death touch. Can you give me one number: the average intelligence score of the superheroes who have either of those powers? Round it to one decimal place, and only count the heroes who actually have an intelligence score in the database.
"Super speed" and "death touch" are superpower names as used in the database; "intelligence" is the hero attribute by that name.
SELECT ROUND(AVG(v), 1) AS average_intelligence FROM (SELECT DISTINCT T1.id, T4.attribute_value AS v FROM superhero AS T1 INNER JOIN hero_power AS T2 ON T1.id = T2.hero_id INNER JOIN superpower AS T3 ON T2.power_id = T3.id INNER JOIN hero_attribute AS T4 ON T4.hero_id = T1.id INNER JOIN attribute AS T5 ON T4.attribute_...
challenging
365
superhero
I'm comparing how power-rich male and female heroes are. For all male heroes and all female heroes that have a documented real full name, what is the average number of superpowers per hero for each gender? Please compute each average over the entire hero population of that gender, not just the heroes that happen to hav...
Full name: the hero's real, full personal name (first name plus last name, and optionally middle names); single names such as mononyms or aliases are not a full name.
SELECT ROUND(CAST(SUM(CASE WHEN g.gender = 'Male' THEN COALESCE(pc.cnt, 0) ELSE 0 END) AS REAL) / SUM(CASE WHEN g.gender = 'Male' THEN 1 ELSE 0 END), 2) AS avg_superpowers_male, ROUND(CAST(SUM(CASE WHEN g.gender = 'Female' THEN COALESCE(pc.cnt, 0) ELSE 0 END) AS REAL) / SUM(CASE WHEN g.gender = 'Female' THEN 1 ELSE 0 E...
challenging
366
superhero
I'm putting together a physical profile of the green-skinned villain corner of the universe for a fan wiki page. Could you tell me the average height in centimetres and the average weight in kilograms of the green-skinned villains? Please average only over the characters whose measurement is actually on record - a char...
By 'villain' I mean a character whose alignment is Bad, and by 'green-skinned' I mean a character whose skin colour is Green. Height in centimetres and weight in kilograms are the character's height_cm and weight_kg as commonly understood physical measurements.
SELECT ROUND(AVG(CASE WHEN T1.height_cm > 0 THEN T1.height_cm END), 2) AS avg_height_cm, ROUND(AVG(CASE WHEN T1.weight_kg > 0 THEN T1.weight_kg END), 2) AS avg_weight_kg FROM superhero AS T1 INNER JOIN alignment AS T2 ON T1.alignment_id = T2.id INNER JOIN colour AS T3 ON T1.skin_colour_id = T3.id WHERE T2.alignment = '...
challenging
367
superhero
I'm profiling publisher rosters and now want to look at the physical build of George Lucas's heroes. What is the average height of the heroes he created, in centimetres, and their average weight, in kilograms? Please round each average to one decimal place, and only include heroes whose height (for the height average) ...
SELECT ROUND(AVG(CASE WHEN s.height_cm > 0 THEN s.height_cm END), 1) AS average_height_cm, ROUND(AVG(CASE WHEN s.weight_kg > 0 THEN s.weight_kg END), 1) AS average_weight_kg FROM superhero AS s INNER JOIN publisher AS p ON s.publisher_id = p.id WHERE p.publisher_name = 'George Lucas'
challenging
368
superhero
I'd like to know how tall the heroes are who share at least one superpower with 3-D Man. Can you give me the average height in centimetres of those heroes, rounded to one decimal place? Please leave 3-D Man himself out of it, and don't count heroes whose height isn't known.
SELECT ROUND(AVG(s.height_cm), 1) AS avg_height_cm FROM superhero AS s WHERE s.height_cm > 0 AND s.id <> (SELECT id FROM superhero WHERE superhero_name = '3-D Man') AND s.id IN (SELECT hp2.hero_id FROM hero_power AS hp2 WHERE hp2.power_id IN (SELECT power_id FROM hero_power WHERE hero_id = (SELECT id FROM superhero WHE...
challenging
369
superhero
I'm writing an article about green-skinned flying villains and need a body-statistics fact. What is the average weight, in kilograms, of all green-skinned villains who can fly? By villain I mean a character whose moral affiliation is Bad. Please include only characters whose weight was actually measured-any character w...
Flight: the power to fly.
SELECT ROUND(AVG(CASE WHEN s.weight_kg > 0 THEN s.weight_kg END)) AS average_weight_kg FROM superhero AS s INNER JOIN alignment AS a ON s.alignment_id = a.id INNER JOIN colour AS c ON s.skin_colour_id = c.id INNER JOIN hero_power AS hp ON hp.hero_id = s.id INNER JOIN superpower AS sp ON sp.id = hp.power_id WHERE a.alig...
challenging
370
superhero
I'm doing a physical-profile breakdown of the George Lucas catalogue. For the heroes published by George Lucas that have at least one superpower in the database, what is their average weight in kilograms, counting only the heroes whose weight is recorded? Please give me just that one number, rounded to two decimal plac...
George Lucas refers to the publisher name.
SELECT ROUND(AVG(CASE WHEN s.weight_kg > 0 THEN s.weight_kg END), 2) AS avg_weight_kg FROM superhero AS s INNER JOIN publisher AS p ON s.publisher_id = p.id WHERE p.publisher_name = 'George Lucas' AND EXISTS (SELECT 1 FROM hero_power AS hp WHERE hp.hero_id = s.id)
challenging
371
superhero
For the article I'm writing on heroic female characters, I'd like a physique stat for the trivia box: what is the average weight in kilograms of female superheroes whose alignment is good? Only count superheroes whose weight is known. Please round the result to two decimal places.
Alignment: the superhero's moral category, e.g. good, bad, neutral.
SELECT ROUND(AVG(s.weight_kg), 2) AS average_weight_kg FROM superhero AS s JOIN gender AS g ON g.id = s.gender_id JOIN alignment AS a ON a.id = s.alignment_id WHERE g.gender = 'Female' AND a.alignment = 'Good' AND s.weight_kg > 0
challenging
372
superhero
I'm picking powers for a lightweight male hero archetype. How many different superpowers are held by at least one male superhero who weighs under 70 kilograms? Heroes whose weight isn't recorded shouldn't count as weighing under 70.
SELECT COUNT(DISTINCT hp.power_id) AS power_count FROM superhero AS s JOIN hero_power AS hp ON hp.hero_id = s.id JOIN superpower AS sp ON sp.id = hp.power_id JOIN gender AS g ON g.id = s.gender_id WHERE g.gender = 'Male' AND s.weight_kg > 0 AND s.weight_kg < 70;
challenging
373
superhero
I'm putting together a trivia fact box on tiny heroes. Could you tell me the hair colour of the shortest human superhero? Please treat heroes with no recorded height as unmeasured rather than as being the shortest. I just need the colour, nothing else.
SELECT DISTINCT c.colour FROM superhero AS s INNER JOIN race AS r ON s.race_id = r.id INNER JOIN colour AS c ON s.hair_colour_id = c.id WHERE r.race = 'Human' AND s.height_cm = (SELECT MIN(x.height_cm) FROM superhero AS x INNER JOIN race AS y ON x.race_id = y.id WHERE y.race = 'Human' AND x.height_cm > 0)
challenging
374
superhero
I want to know about the lightest superhero whose weight has actually been recorded. Among all heroes sharing that lightest weight, give me the largest number of superpowers any of them has. If such a hero has no powers, that counts as 0. Please return just that one number.
A superpower is one power a hero has, identified by its name.
SELECT MAX(cnt) AS power_count FROM (SELECT COUNT(hp.power_id) AS cnt FROM superhero AS h LEFT JOIN hero_power hp ON h.id = hp.hero_id WHERE h.weight_kg = (SELECT MIN(weight_kg) FROM superhero WHERE weight_kg > 0) GROUP BY h.id)
challenging
375
superhero
I'm auditing identity info on our hero profile pages. How many neutral-alignment heroes have a known full name? Just give me the count.
By "full name" I mean the hero's real-world identity name, not the superhero/costume name.
SELECT COUNT(*) AS neutral_heroes_with_known_full_name FROM superhero AS T1 INNER JOIN alignment AS T2 ON T1.alignment_id = T2.id WHERE T2.alignment = 'Neutral' AND T1.full_name IS NOT NULL AND T1.full_name <> '-'
challenging
376
superhero
I'm building a profile page crediting the fastest characters. Among all superheroes that share the top Speed attribute value (everyone tied at the highest Speed value counts), can you list the ones whose real name is known? For each, I need the superhero name and the full name — the civilian identity behind the mask — ...
SELECT s.superhero_name, s.full_name FROM superhero AS s JOIN hero_attribute AS h ON h.hero_id = s.id JOIN attribute AS a ON a.id = h.attribute_id WHERE a.attribute_name = 'Speed' AND h.attribute_value = ( SELECT MAX(h2.attribute_value) FROM hero_attribute AS h2 JOIN attribute AS a2 ON a2.id = h2.attribute_id WHERE a2....
challenging
377
superhero
I'm looking at how designers pair hair and eye colours. For every eye colour that appears on at least one brown-haired hero, how many heroes have that eye colour while their hair is NOT brown? Just give me each eye colour and that count, listing the eye colour with the highest count first. If two eye colours have the s...
By a brown-haired hero I mean a hero whose hair colour is Brown.
WITH cohort AS (SELECT DISTINCT s.eye_colour_id AS eid FROM superhero AS s INNER JOIN colour AS h ON s.hair_colour_id = h.id WHERE h.colour = 'Brown') SELECT c.colour AS eye_colour, COUNT(CASE WHEN h.colour <> 'Brown' THEN 1 END) AS heroes FROM cohort AS t INNER JOIN colour AS c ON c.id = t.eid LEFT JOIN superhero AS s...
challenging
378
superhero
I'm preparing a report on Marvel's roster and want to gauge how heroic their catalogued heroes are. Among Marvel Comics superheroes whose civilian full name is documented, what percentage are good? Please give me just that single percentage, rounded to two decimal places. Note: the percentage should be taken over all M...
Good refers to alignment = 'Good'. A full name means the hero's real-world civilian identity, i.e. an actual person's name such as 'Charles Chandler' or 'Richard Milhouse Jones'.
SELECT ROUND(CAST(SUM(CASE WHEN T3.alignment = 'Good' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*), 2) AS percentage FROM superhero AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.id LEFT JOIN alignment AS T3 ON T1.alignment_id = T3.id WHERE T2.publisher_name = 'Marvel Comics' AND T1.full_name IS NOT NULL AND ...
challenging
379
superhero
What percentage of Marvel Comics superheroes with a recorded superpower are classified as good? Round the percentage to two decimal places, and give me just that single value.
Good means alignment 'Good'; superpower refers to a hero's recorded power.
SELECT ROUND(CAST(SUM(CASE WHEN a.alignment = 'Good' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*), 2) AS good_percentage FROM superhero s JOIN publisher p ON s.publisher_id = p.id LEFT JOIN alignment a ON s.alignment_id = a.id WHERE p.publisher_name = 'Marvel Comics' AND EXISTS (SELECT 1 FROM hero_power hp WHERE hp.her...
challenging
380
superhero
I'm comparing the builds of heroes whose power sets overlap with 3-D Man's. What is the average weight in kg of the heroes other than 3-D Man that share at least one superpower with him? Please round it to two decimal places, leave out any heroes whose weight isn't recorded, and return just that single number.
SELECT ROUND(AVG(weight_kg), 2) AS average_weight_kg FROM superhero WHERE superhero_name <> '3-D Man' AND weight_kg > 0 AND id IN (SELECT hero_id FROM hero_power WHERE power_id IN (SELECT power_id FROM hero_power WHERE hero_id = (SELECT id FROM superhero WHERE superhero_name = '3-D Man')))
challenging
381
superhero
Among superheroes whose weight is not recorded, how many more have the 'No Colour' eye category than have blue eyes? I want a single whole number: the count of 'No Colour' eyes minus the count of blue eyes in that group - it can be negative if blue is more common. Please give me just that one number, with no other resu...
'No Colour' is an eye category meaning the hero's eye colour is unspecified.
SELECT SUM(CASE WHEN co.colour = 'No Colour' THEN 1 ELSE 0 END) - SUM(CASE WHEN co.colour = 'Blue' THEN 1 ELSE 0 END) AS diff FROM superhero AS s JOIN colour AS co ON co.id = s.eye_colour_id WHERE s.weight_kg = 0 OR s.weight_kg IS NULL
challenging
382
thrombosis_prediction
Among distinct patients with at least one uric-acid result above the sex-specific upper limit, what is the ratio of male to female patients?
For this task, the uric-acid upper limit is 8.0 for males and 6.5 for females.
SELECT CAST(SUM(CASE WHEN p.SEX = 'M' THEN 1 ELSE 0 END) AS REAL) / NULLIF(SUM(CASE WHEN p.SEX = 'F' THEN 1 ELSE 0 END), 0) FROM Patient AS p WHERE (p.SEX = 'M' AND EXISTS (SELECT 1 FROM Laboratory AS l WHERE l.ID = p.ID AND l.UA > 8.0)) OR (p.SEX = 'F' AND EXISTS (SELECT 1 FROM Laboratory AS l WHERE l.ID = p.ID AND l....
challenging
383
thrombosis_prediction
Across laboratory records with PLT > 400 for female patients whose patient profile lists an SLE diagnosis, what is the average ALB value rounded to four decimal places?
SELECT ROUND(AVG(CAST(l.ALB AS DECIMAL(10, 4))), 4) FROM Patient AS p JOIN Laboratory AS l ON l.ID = p.ID WHERE l.PLT > 400 AND ((',' || REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(COALESCE(p.Diagnosis, ''), CHAR(13), ','), CHAR(10), ','), CHAR(29), ','), CHAR(11), ','), ' ', ','), ' ', '') || ',') LIKE '%,SLE,%' ...
moderate
384
thrombosis_prediction
How many distinct patients with a triglyceride result of at least 200 were older than 50 on 2026-10-09?
SELECT COUNT(*) FROM Patient AS p WHERE p.Birthday < '1976-10-09' AND EXISTS (SELECT 1 FROM Laboratory AS l WHERE l.ID = p.ID AND l.TG >= 200)
moderate
385
thrombosis_prediction
List patient IDs, sex, and completed age on 2026-10-09 for patients with at least one laboratory record showing glucose at least 180 and total cholesterol below 250.
SELECT p.ID, p.SEX, (CAST(SUBSTR(CAST('2026-10-09' AS CHAR(10)), 1, 4) AS DECIMAL(4,0)) - CAST(SUBSTR(CAST(p.Birthday AS CHAR(10)), 1, 4) AS DECIMAL(4,0)) - CASE WHEN SUBSTR(CAST('2026-10-09' AS CHAR(10)), 6, 5) < SUBSTR(CAST(p.Birthday AS CHAR(10)), 6, 5) THEN 1 ELSE 0 END) AS age FROM Patient AS p WHERE p.Birthday IS...
challenging
386
thrombosis_prediction
List the IDs and completed ages on 2026-10-09 of patients with at least two laboratory results having hematocrit of 52 or higher.
SELECT p.ID, (CAST(SUBSTR(CAST('2026-10-09' AS CHAR(10)), 1, 4) AS DECIMAL(4,0)) - CAST(SUBSTR(CAST(p.Birthday AS CHAR(10)), 1, 4) AS DECIMAL(4,0)) - CASE WHEN SUBSTR(CAST('2026-10-09' AS CHAR(10)), 6, 5) < SUBSTR(CAST(p.Birthday AS CHAR(10)), 6, 5) THEN 1 ELSE 0 END) AS age FROM Patient AS p JOIN (SELECT ID FROM Labor...
challenging
387
thrombosis_prediction
Among patients older than 55 on 2026-10-09 who have at least one abnormal PT result, what percentage are female? Round to two decimals.
For this task, PT of at least 14 is abnormal.
SELECT ROUND(100.0 * SUM(CASE WHEN p.SEX = 'F' THEN 1 ELSE 0 END) / NULLIF(COUNT(*), 0), 2) FROM Patient AS p WHERE p.Birthday < '1971-10-09' AND EXISTS (SELECT 1 FROM Laboratory AS l WHERE l.ID = p.ID AND l.PT >= 14)
challenging
388
thrombosis_prediction
How many distinct patients have at least one positive CRP laboratory result and no recorded patient description?
Plus-marked CRP results indicate positivity.
SELECT COUNT(DISTINCT p.ID) FROM Patient AS p JOIN Laboratory AS l ON l.ID = p.ID WHERE l.CRP LIKE '%+' AND p.Description IS NULL
moderate
389
thrombosis_prediction
How many distinct female patients have a normal anti-Scl-70 result and no recorded non-null symptom on any examination?
Normal anti-Scl-70 is recorded as 'negative' or '0'.
SELECT COUNT(*) FROM Patient AS p WHERE p.SEX = 'F' AND EXISTS (SELECT 1 FROM Laboratory AS l WHERE l.ID = p.ID AND l.SC170 IN ('negative', '0')) AND NOT EXISTS (SELECT 1 FROM Examination AS e WHERE e.ID = p.ID AND e.Symptoms IS NOT NULL)
challenging
390
thrombosis_prediction
Among patients in the thrombosis registry born between 1930 and 1940 inclusive who had laboratory tests, what percentage were inpatients? Please give me just the percentage rounded to two decimal places.
An inpatient is a patient who was admitted to the hospital; an outpatient is a patient who was followed at the outpatient clinic.
SELECT ROUND(CAST(SUM(CASE WHEN Admission = '+' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*), 2) AS percentage FROM Patient WHERE STRFTIME('%Y', Birthday) BETWEEN '1930' AND '1940' AND ID IN (SELECT ID FROM Laboratory)
challenging
391
thrombosis_prediction
Among the lab tests with the strongest anti-ribonuclear protein result (i.e., the highest result value), find the highest total bilirubin level and give me that test's total bilirubin level, the date of the lab test, the patient's ID, sex, and birthday. If several of those tests share the highest total bilirubin level,...
Anti-ribonuclear protein refers to the anti-RNP antibody lab test; total bilirubin refers to the total serum bilirubin lab test (a liver marker).
SELECT T2.`T-BIL`, T2.`Date`, T1.ID, T1.SEX, T1.Birthday FROM `Patient` AS T1 INNER JOIN `Laboratory` AS T2 ON T1.ID = T2.ID WHERE CAST(T2.`RNP` AS REAL) = (SELECT MAX(CAST(`RNP` AS REAL)) FROM `Laboratory`) AND T2.`T-BIL` = (SELECT MAX(`T-BIL`) FROM `Laboratory` WHERE CAST(`RNP` AS REAL) = (SELECT MAX(CAST(`RNP` AS RE...
challenging
392
thrombosis_prediction
I'm describing our young-patient group and want to show how unusual a raised RNP antibody is in these patients. Could you tell me how many patients in the thrombosis cohort born after 1 January 1960 never had a raised RNP antibody result? A few points: the group should cover every patient born after that date, includin...
RNP: anti-ribonuclear protein antibody; a result of "negative" means no antibody was detected. A raised RNP result is a laboratory result strictly above 10.
SELECT COUNT(*) AS patient_count FROM Patient AS p WHERE p.Birthday > '1960-01-01' AND NOT EXISTS (SELECT 1 FROM Laboratory AS l WHERE l.ID = p.ID AND l.RNP IS NOT NULL AND l.RNP <> 'negative' AND CAST(l.RNP AS REAL) > 10)
challenging
393
thrombosis_prediction
Among patients followed at the outpatient clinic who ever had an abnormal anti-SSA result, which one showed the highest anti-RNP titer? Please give me the patient's ID and the anti-RNP titer value. This should cover the hospital's full records across all years, and if several patients tie for the highest anti-RNP titer...
Abnormal anti-SSA means any SSA result other than negative or 0. "Followed at the outpatient clinic" is the admission status marked with a minus sign. Anti-RNP titer is the strength of the anti-ribonuclear protein result.
WITH cohort AS (SELECT DISTINCT T1.ID FROM Patient AS T1 JOIN Laboratory AS T2 ON T1.ID = T2.ID WHERE T1.Admission = '-' AND T2.SSA IS NOT NULL AND T2.SSA NOT IN ('negative', '0')), titers AS (SELECT T.ID, T.RNP FROM Laboratory AS T JOIN cohort AS C ON T.ID = C.ID WHERE T.RNP IS NOT NULL AND T.RNP <> 'negative') SELECT...
challenging
394
thrombosis_prediction
I'm studying antibody and platelet profiles in mixed connective tissue disease (MCTD). Can you tell me how many patients diagnosed with MCTD alone - meaning MCTD is their only recorded diagnosis - have had at least one platelet reading within the normal range and at least one anti-RNP antibody level above 5 (strictly g...
A platelet level within the normal range means from 100 to 400, both ends included; below 100 or above 400 is outside the normal range.
SELECT COUNT(DISTINCT T1.ID) AS patient_count FROM Patient AS T1 WHERE T1.Diagnosis = 'MCTD' AND T1.ID IN (SELECT ID FROM Laboratory WHERE PLT BETWEEN 100 AND 400) AND T1.ID IN (SELECT ID FROM Laboratory WHERE CAST(RNP AS REAL) > 5)
challenging
395
thrombosis_prediction
As part of the data-completeness review, I'd like to know how much laboratory follow-up our never-examined patients actually have, split by sex. Could you give me, for each sex (F and M), the average number of laboratory test dates recorded for the patients of that sex who have no examination record at all? Please cove...
F denotes a female patient and M denotes a male patient. A laboratory test date is a date on which laboratory tests were recorded for a patient.
SELECT p.SEX, ROUND(AVG(COALESCE(c.n_dates, 0)), 2) AS avg_lab_test_dates FROM Patient p LEFT JOIN (SELECT ID, COUNT(*) AS n_dates FROM Laboratory GROUP BY ID) c ON c.ID = p.ID WHERE p.SEX IN ('F', 'M') AND NOT EXISTS (SELECT 1 FROM Examination WHERE Examination.ID = p.ID) GROUP BY p.SEX
challenging
396
thrombosis_prediction
I'm reviewing autoimmune antibody profiles in our thrombosis registry. Among the female patients who were admitted to the hospital as inpatients, I need to find the laboratory test record with the highest anti-DNA antibody level, for a case review. Please give me the patient ID, the laboratory test date of that record,...
Anti-DNA antibody level means the anti-DNA test result recorded in the laboratory tests.
SELECT p.ID, l.Date, l.DNA AS anti_dna FROM Patient p JOIN Laboratory l ON l.ID = p.ID WHERE p.SEX = 'F' AND p.Admission = '+' AND l.DNA IS NOT NULL AND CAST(l.DNA AS REAL) = (SELECT MAX(CAST(l2.DNA AS REAL)) FROM Laboratory l2 JOIN Patient p2 ON p2.ID = l2.ID WHERE p2.SEX = 'F' AND p2.Admission = '+' AND l2.DNA IS NOT...
challenging
397
thrombosis_prediction
Among patients who have ever had an anti-ribonuclear protein (anti-RNP) antibody result above 16 on any laboratory reading, whenever it was taken, how many were admitted to the hospital and how many were followed at the outpatient clinic? Please give one row per care setting, using '+' for admitted to the hospital and ...
SELECT P.Admission AS care_setting, COUNT(DISTINCT P.ID) AS patients FROM Patient P WHERE P.Admission IN ('+', '-') AND EXISTS (SELECT 1 FROM Laboratory L WHERE L.ID = P.ID AND CAST(L.RNP AS REAL) > 16) GROUP BY P.Admission ORDER BY care_setting
challenging
398
thrombosis_prediction
Among the thrombosis registry patients followed at the outpatient clinic, how many have a non-normal hematocrit and an anti-ribonuclear protein measurement above 16? I need a single count. A patient counts if they have at least one hematocrit reading outside the normal range, regardless of test date, and at least one a...
Hematocrit is normal when the value lies strictly between 29 and 52; outside that range it is abnormal. A negative anti-ribonuclear protein result means none was detected.
WITH cohort AS (SELECT DISTINCT p.ID FROM Patient p JOIN Laboratory l ON p.ID = l.ID WHERE p.Admission = '-' AND (l.HCT >= 52 OR l.HCT <= 29)) SELECT COUNT(DISTINCT l.ID) AS patient_count FROM Laboratory l WHERE l.ID IN (SELECT ID FROM cohort) AND l.RNP IS NOT NULL AND CAST(l.RNP AS REAL) > 16
challenging
399
thrombosis_prediction
For the patients followed at our thrombosis unit's outpatient clinic, what is the highest anti-ribonuclear protein value on record? I just need that single highest value for my review.
Anti-ribonuclear protein (anti-RNP) is a blood antibody test result recorded for patients.
SELECT MAX(CAST(l.RNP AS REAL)) AS highest_anti_ribonuclear_protein_value FROM Laboratory AS l INNER JOIN Patient AS p ON p.ID = l.ID WHERE p.Admission = '-'
challenging