human
Schema:
company (Company_ID, Rank, Company, Headquarters, Main_Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value)
gas_station (Station_ID, Open_Year, Location, Manager_Name, Vice_Manager_Name, Representative_Name)
station_company (Station_ID, Company_ID, Rank_of_the_Year)
Please answer with SQL.
assistant
Sure, I understand.
human
Show all headquarters without a company in banking industry.
assistant
SELECT headquarters FROM company EXCEPT SELECT headquarters FROM company WHERE main_industry = 'Banking'
human
Show company name and main industry without a gas station.
assistant
SELECT company , main_industry FROM company WHERE company_id NOT IN (SELECT company_id FROM station_company)
human
find the location and Representative name of the gas stations owned by the companies with top 3 Asset amounts.
assistant
SELECT T3.location , T3.Representative_Name FROM station_company AS T1 JOIN company AS T2 ON T1.company_id = T2.company_id JOIN gas_station AS T3 ON T1.station_id = T3.station_id ORDER BY T2.Assets_billion DESC LIMIT 3
human
How many gas companies are there?
assistant
SELECT count(*) FROM company
human
Show headquarters with at least two companies in the banking industry.
assistant
SELECT headquarters FROM company WHERE main_industry = 'Banking' GROUP BY headquarters HAVING count(*) >= 2
human
What are the headquarters that have both a company in the banking and 'oil and gas' industries?
assistant
SELECT headquarters FROM company WHERE main_industry = "Banking" INTERSECT SELECT headquarters FROM company WHERE main_industry = "Oil AND gas" ;