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
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
How many different industries are the companies in?
assistant
SELECT count(DISTINCT Industry) FROM Companies
human
What are the average profits of companies?
assistant
SELECT avg(Profits_billion) FROM Companies
human
Find the number of companies whose industry is 'Banking' or 'Conglomerate',
assistant
SELECT count(*) FROM Companies WHERE Industry = 'Banking' OR Industry = 'Conglomerate'
human
What are the maximum and minimum sales of the companies whose industries are not 'Banking'.
assistant
SELECT MAX( Sales_billion ) , MIN( Sales_billion ) FROM Companies WHERE Industry != "Banking" ;