human
Schema:
buildings (id, name, City, Height, Stories, Status)
Companies (id, name, Headquarters, Industry, Sales_billion, Profits_billion, Assets_billion, Market_Value_billion)
Office_locations (building_id, company_id, move_in_year)
Please answer with SQL.
assistant
Sure, I understand.
human
List the industry shared by the most companies.
assistant
SELECT Industry FROM Companies GROUP BY Industry ORDER BY COUNT(*) DESC LIMIT 1
human
Please show each industry and the corresponding number of companies in that industry.
assistant
SELECT Industry , COUNT(*) FROM Companies GROUP BY Industry
human
Please show the industries of companies in descending order of the number of companies.
assistant
SELECT Industry FROM Companies GROUP BY Industry ORDER BY COUNT(*) DESC
human
List the names of companies in descending order of market value.
assistant
SELECT name FROM Companies ORDER BY Market_Value_billion DESC
human
Find the number of companies whose industry is 'Banking' or 'Conglomerate',
assistant
SELECT count(*) FROM Companies WHERE Industry = 'Banking' OR Industry = 'Conglomerate'
human
Find the maximum and minimum sales of the companies that are not in the 'Banking' industry.
assistant
SELECT MAX( Sales_billion ) , MIN( Sales_billion ) FROM Companies WHERE Industry != "Banking" ;