human
Schema:
storm (Storm_ID, Name, Dates_active, Max_speed, Damage_millions_USD, Number_Deaths)
region (Region_id, Region_code, Region_name)
affected_region (Region_id, Storm_ID, Number_city_affected)
Please answer with SQL.
assistant
Sure, I understand.
human
What is the storm name and max speed which affected the greatest number of regions?
assistant
SELECT T1.name , T1.max_speed FROM storm AS T1 JOIN affected_region AS T2 ON T1.storm_id = T2.storm_id GROUP BY T1.storm_id ORDER BY count(*) DESC LIMIT 1
human
Show the name of storms which don't have affected region in record.
assistant
SELECT name FROM storm WHERE storm_id NOT IN (SELECT storm_id FROM affected_region)
human
What is the total number of deaths and damage for all storms with a max speed greater than the average?
assistant
SELECT sum(number_deaths) , sum(damage_millions_USD) FROM storm WHERE max_speed > (SELECT avg(max_speed) FROM storm)
human
What are the region names affected by the storm with a number of deaths of least 10?
assistant
SELECT T2.region_name FROM affected_region AS T1 JOIN region AS T2 ON T1.region_id = T2.region_id JOIN storm AS T3 ON T1.storm_id = T3.storm_id WHERE T3.number_deaths >= 10
human
List name, dates active, and number of deaths for all storms with at least 1 death.
assistant
SELECT name , dates_active , number_deaths FROM storm WHERE number_deaths >= 1
human
How many storms had death records?
assistant
SELECT COUNT( * ) FROM storm WHERE Number_Deaths > 0 ;