instruction
stringlengths 0
1.06k
| input
stringlengths 11
5.3k
| response
stringlengths 2
4.44k
|
---|---|---|
List the total cargo weight for each cargo type in the 'cargo_tracking' table
|
CREATE TABLE cargo_tracking (cargo_id INT,cargo_type VARCHAR(255),weight INT);
|
SELECT cargo_type, SUM(weight) FROM cargo_tracking GROUP BY cargo_type;
|
List the union membership statistics for unions in the 'north_region' that have more than 3000 members?
|
CREATE TABLE union_stats (union_name TEXT,region TEXT,members INTEGER); INSERT INTO union_stats (union_name,region,members) VALUES ('Union A','north_region',4000),('Union B','south_region',2000),('Union C','north_region',6000);
|
SELECT union_name, members FROM union_stats WHERE region = 'north_region' AND members > 3000;
|
Delete all records from the 'safety_record' table that have a 'report_date' before 2020-01-01
|
CREATE TABLE safety_record (product_id INT,report_date DATE,report_status TEXT);
|
DELETE FROM safety_record WHERE report_date < '2020-01-01';
|
What is the total weight of materials used in each country's production?
|
CREATE TABLE MaterialProduction (item_id INT,country VARCHAR(255),material VARCHAR(255),weight DECIMAL(5,2)); INSERT INTO MaterialProduction (item_id,country,material,weight) VALUES (1,'Spain','Cotton',2.5),(1,'Italy','Polyester',1.5),(2,'France','Wool',3.0),(3,'Spain','Silk',4.0),(4,'Italy','Cotton',2.0);
|
SELECT country, SUM(weight) FROM MaterialProduction GROUP BY country;
|
Compare the number of wells drilled in Saudi Arabia and Iran.
|
CREATE TABLE wells (well_id INT,country VARCHAR(50)); INSERT INTO wells (well_id,country) VALUES (1,'Saudi Arabia'),(2,'Iran'),(3,'Iraq');
|
SELECT 'Saudi Arabia' as country, COUNT(*) as num_wells FROM wells WHERE country = 'Saudi Arabia' UNION ALL SELECT 'Iran' as country, COUNT(*) as num_wells FROM wells WHERE country = 'Iran';
|
Update the vendor_contracts table to set the 'contract_value' to NULL for any contract with 'vendor_name' = 'ABC Defense'
|
CREATE TABLE vendor_contracts (vendor_id INT,vendor_name VARCHAR(50),contract_id INT,contract_value DECIMAL(10,2));
|
UPDATE vendor_contracts SET contract_value = NULL WHERE vendor_name = 'ABC Defense';
|
Which suppliers in the suppliers table are not from the USA?
|
CREATE TABLE suppliers (id INT,name TEXT,country TEXT); INSERT INTO suppliers (id,name,country) VALUES (1,'Green Garden','France'); INSERT INTO suppliers (id,name,country) VALUES (2,'SunRise','Italy'); INSERT INTO suppliers (id,name,country) VALUES (3,'Local Farms','USA');
|
SELECT name FROM suppliers WHERE country != 'USA';
|
What is the percentage of food safety inspections with critical violations for each location in the past year?
|
CREATE TABLE food_safety_inspections (location VARCHAR(255),inspection_date DATE,critical_violations INT); INSERT INTO food_safety_inspections (location,inspection_date,critical_violations) VALUES ('Location A','2022-01-01',1),('Location B','2022-01-02',0),('Location A','2022-01-03',1),('Location C','2022-01-04',1),('Location A','2022-01-05',0);
|
SELECT location, (SUM(critical_violations) * 100.00 / COUNT(*)) as percentage_critical_violations FROM food_safety_inspections WHERE inspection_date BETWEEN DATEADD(year, -1, GETDATE()) AND GETDATE() GROUP BY location;
|
Update the waste generation for region 'South' in the year 2022 to 75000 gram.
|
CREATE TABLE waste_generation(region VARCHAR(20),year INT,waste_gram INT); INSERT INTO waste_generation(region,year,waste_gram) VALUES('North',2021,50000),('North',2022,60000),('South',2021,40000),('South',2022,70000);
|
UPDATE waste_generation SET waste_gram = 75000 WHERE region = 'South' AND year = 2022;
|
Delete records with a budget under 50000 in the 'community_development' table
|
CREATE TABLE community_development (id INT,project_name VARCHAR(255),budget INT,country VARCHAR(255));
|
DELETE FROM community_development WHERE budget < 50000;
|
What is the percentage of players who have played a VR game in each region?
|
CREATE TABLE PlayerVR (PlayerID INT,Region VARCHAR(50)); INSERT INTO PlayerVR (PlayerID,Region) VALUES (1,'North America'),(2,'Europe'),(3,'Asia'),(4,'South America'),(5,'Europe'),(6,'North America'),(7,'Asia'),(8,'North America'),(9,'Europe'),(10,'Asia'); CREATE TABLE PlayerActivity (PlayerID INT,GameID INT,VRGame INT); INSERT INTO PlayerActivity (PlayerID,GameID,VRGame) VALUES (1,1,1),(2,2,0),(3,1,1),(4,3,0),(5,2,1),(6,1,1),(7,4,0),(8,3,1),(9,2,1),(10,4,0);
|
SELECT Region, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM PlayerVR) as Percentage FROM PlayerVR INNER JOIN PlayerActivity ON PlayerVR.PlayerID = PlayerActivity.PlayerID WHERE VRGame = 1 GROUP BY Region;
|
Update the location of the Giant Panda habitat
|
CREATE TABLE habitats (id INT PRIMARY KEY,name VARCHAR(255),location VARCHAR(255),size FLOAT);
|
UPDATE habitats SET location = 'China' WHERE name = 'Giant Panda Habitat';
|
How many female and male founders are there in total?
|
CREATE TABLE company (id INT,name VARCHAR(255),founder VARCHAR(255),founder_gender VARCHAR(10)); INSERT INTO company (id,name,founder,founder_gender) VALUES (1,'Acme Inc','Alex','male'),(2,'Beta Corp','Jasmine','female');
|
SELECT founder_gender, COUNT(*) FROM company GROUP BY founder_gender;
|
What is the total number of safety incidents in the 'safety_records' table?
|
CREATE TABLE safety_records (record_id INT,vessel_name VARCHAR(50),incidents INT); INSERT INTO safety_records (record_id,vessel_name,incidents) VALUES (1,'VesselA',2),(2,'VesselB',1),(3,'VesselC',3);
|
SELECT SUM(incidents) FROM safety_records;
|
Rank the language preservation initiatives in Europe by their total funding, with the highest funded initiative first.
|
CREATE TABLE Funding (FundingID INT,Initiative VARCHAR(255),Country VARCHAR(255),FundingAmount INT,PRIMARY KEY (FundingID));
|
SELECT Initiative, FundingAmount FROM (SELECT Initiative, Country, FundingAmount, ROW_NUMBER() OVER (ORDER BY FundingAmount DESC) AS Rank FROM Funding WHERE Country = 'Europe') AS FundingRanks WHERE Rank = 1;
|
Who are the top 3 music artists by album sales in the US?
|
CREATE TABLE album_sales (artist_id INT PRIMARY KEY,name VARCHAR(255),country VARCHAR(2),sales INT); INSERT INTO album_sales (artist_id,name,country,sales) VALUES (1,'Talyor Swift','USA',3000000),(2,'Adele','UK',2500000),(3,'Post Malone','USA',2200000);
|
SELECT * FROM album_sales WHERE country = 'USA' ORDER BY sales DESC LIMIT 3;
|
Which mines in the Ural Mountains have a cleanup cost greater than 15000?
|
CREATE TABLE mines (id INT PRIMARY KEY,name VARCHAR(255),location VARCHAR(255)); INSERT INTO mines (id,name,location) VALUES (1,'Bakcharskoye','Russia'); INSERT INTO mines (id,name,location) VALUES (2,'Maly Alluai','Russia'); CREATE TABLE environmental_impact (id INT PRIMARY KEY,mine_id INT,pollution_level INT,cleanup_cost FLOAT); INSERT INTO environmental_impact (id,mine_id,pollution_level,cleanup_cost) VALUES (1,1,5,20000); INSERT INTO environmental_impact (id,mine_id,pollution_level,cleanup_cost) VALUES (2,2,3,12000);
|
SELECT m.name, e.cleanup_cost FROM mines m JOIN environmental_impact e ON m.id = e.mine_id WHERE m.location = 'Ural Mountains' GROUP BY m.name HAVING e.cleanup_cost > 15000;
|
What is the total number of packages shipped from warehouse A to country Mexico?
|
CREATE TABLE warehouses (warehouse_id INT,warehouse_name VARCHAR(255)); INSERT INTO warehouses (warehouse_id,warehouse_name) VALUES (1,'Warehouse A'); CREATE TABLE shipments (shipment_id INT,warehouse_id INT,country VARCHAR(255)); INSERT INTO shipments (shipment_id,warehouse_id,country) VALUES (1,1,'Mexico');
|
SELECT COUNT(*) FROM shipments s JOIN warehouses w ON s.warehouse_id = w.warehouse_id WHERE w.warehouse_name = 'Warehouse A' AND s.country = 'Mexico';
|
Calculate the total CO2 emissions from all mining activities in 2020.
|
CREATE TABLE co2_emissions (activity VARCHAR(50),co2_emission INT); INSERT INTO co2_emissions (activity,co2_emission) VALUES ('Gold mining',120000),('Silver mining',85000),('Iron ore mining',300000),('Coal mining',520000),('Copper mining',155000),('Zinc mining',75000);
|
SELECT SUM(co2_emission) FROM co2_emissions WHERE activity IN ('Gold mining', 'Silver mining', 'Iron ore mining', 'Coal mining', 'Copper mining', 'Zinc mining');
|
What's the average donation amount for each cause area, excluding any donations less than $100?
|
CREATE TABLE donations (id INT,donor_id INT,organization_id INT,donation_amount FLOAT); CREATE TABLE organizations (id INT,name TEXT,cause_area TEXT);
|
SELECT o.cause_area, AVG(donations.donation_amount) as avg_donation_amount FROM donations INNER JOIN organizations o ON donations.organization_id = o.id WHERE donations.donation_amount >= 100 GROUP BY o.cause_area;
|
What is the average budget allocated to public libraries in the state of New York?
|
CREATE TABLE public_libraries (library_name TEXT,state TEXT,budget INTEGER); INSERT INTO public_libraries (library_name,state,budget) VALUES ('Library A','NY',500000),('Library B','NY',600000),('Library C','CA',400000);
|
SELECT AVG(budget) FROM public_libraries WHERE state = 'NY';
|
What is the average depth of the ocean floor in the Arctic Ocean, excluding areas deeper than 4000 meters?
|
CREATE TABLE ocean_floor (location TEXT,depth INT); INSERT INTO ocean_floor (location,depth) VALUES ('Arctic Ocean - A',3500),('Arctic Ocean - B',2000),('Arctic Ocean - C',4500),('Arctic Ocean - D',3000);
|
SELECT AVG(depth) FROM ocean_floor WHERE ocean = 'Arctic Ocean' AND depth < 4000;
|
Insert a new record into the "player_demographics" table with player_id 4, age 22, and gender "Non-binary"
|
CREATE TABLE player_demographics (player_id INT,age INT,gender VARCHAR(50)); INSERT INTO player_demographics (player_id,age,gender) VALUES (1,25,'Male'),(2,35,'Female'),(3,17,'Female');
|
INSERT INTO player_demographics (player_id, age, gender) VALUES (4, 22, 'Non-binary');
|
Update policy records for policyholders with policy_id 101, 102, and 103 in the 'Policy' table.
|
CREATE TABLE Policy (policy_id INT,policyholder_state VARCHAR(20));
|
UPDATE Policy SET policyholder_state = 'NY' WHERE policy_id IN (101, 102, 103);
|
What is the average donation amount by program in Q1 2021?
|
CREATE TABLE donations (donation_id INT,donation_amount DECIMAL(10,2),program_id INT,donation_date DATE); INSERT INTO donations (donation_id,donation_amount,program_id,donation_date) VALUES (1,50.00,1,'2021-01-01'),(2,100.00,2,'2021-02-01'),(3,75.00,1,'2021-03-01');
|
SELECT program_id, AVG(donation_amount) as avg_donation FROM donations WHERE QUARTER(donation_date) = 1 AND YEAR(donation_date) = 2021 GROUP BY program_id;
|
How many satellites were launched in each year from the Satellite_Table?
|
CREATE TABLE Satellite_Table (id INT,launch_date DATE,satellite_name VARCHAR(100));
|
SELECT YEAR(LAUNCH_DATE), COUNT(*) FROM Satellite_Table GROUP BY YEAR(LAUNCH_DATE);
|
What is the minimum rating of eco-friendly accommodations in Australia?
|
CREATE TABLE eco_accommodations_australia (id INT,country VARCHAR(50),rating DECIMAL(2,1)); INSERT INTO eco_accommodations_australia (id,country,rating) VALUES (1,'Australia',4.2),(2,'Australia',4.5),(3,'Australia',4.8);
|
SELECT MIN(rating) FROM eco_accommodations_australia WHERE country = 'Australia';
|
Show the average quantity of all items in the Inventory table
|
CREATE TABLE Inventory (item_id INT,item_name VARCHAR(50),quantity INT,warehouse_id INT);
|
SELECT AVG(quantity) FROM Inventory;
|
Which defense contracts have a total value greater than $50,000,000?
|
CREATE TABLE defense_contracts (contract_id INT,contract_value FLOAT,contract_description TEXT,vendor_name TEXT,agency_name TEXT); INSERT INTO defense_contracts (contract_id,contract_value,contract_description,vendor_name,agency_name) VALUES (1,75000000,'Aircraft maintenance services','ABC Aerospace','US Air Force'); INSERT INTO defense_contracts (contract_id,contract_value,contract_description,vendor_name,agency_name) VALUES (2,30000000,'Cybersecurity services','DEF Security Solutions','US Army');
|
SELECT contract_id, contract_value, contract_description, vendor_name, agency_name FROM defense_contracts WHERE contract_value > 50000000;
|
How many distinct offenses are present in the justice_data schema's court_cases table, and what is the maximum number of charges filed in a single case?
|
CREATE TABLE justice_data.court_cases (id INT,case_number INT,filing_date DATE,charge_count INT,offense VARCHAR(50));
|
SELECT COUNT(DISTINCT offense), MAX(charge_count) FROM justice_data.court_cases;
|
What is the total fare collected for each mode of transportation, for the last year, ordered by the least profitable mode?
|
CREATE TABLE fare_collection (id INT,trip_id INT,mode VARCHAR(10),fare DECIMAL(5,2)); INSERT INTO fare_collection (id,trip_id,mode,fare) VALUES (1,1,'bus',2.50),(2,2,'metro',3.00),(3,1,'train',5.00);
|
SELECT SUM(fare) OVER (PARTITION BY mode ORDER BY SUM(fare) ASC) as total_fare, mode FROM fare_collection WHERE trip_date >= DATEADD(year, -1, GETDATE()) GROUP BY mode;
|
Who are the top 2 sales representatives by total sales in the Asia-Pacific region in Q1 2021?
|
CREATE TABLE sales_representatives (rep_id INT,rep_name TEXT,region TEXT,quarter INT,total_sales FLOAT); INSERT INTO sales_representatives (rep_id,rep_name,region,quarter,total_sales) VALUES (2001,'RepA','Asia-Pacific',1,1500000),(2002,'RepB','Asia-Pacific',1,1800000),(2003,'RepC','US',1,1200000),(2004,'RepD','Asia-Pacific',1,1600000);
|
SELECT rep_name, SUM(total_sales) AS total_sales FROM sales_representatives WHERE region = 'Asia-Pacific' AND quarter = 1 GROUP BY rep_name ORDER BY total_sales DESC LIMIT 2;
|
Which causes received the most funding from donors aged 30-40 in 2022?
|
CREATE TABLE DonorAge (DonorID INT,DonationYear INT,DonorAge INT,DonationAmount DECIMAL(10,2),DonationCause VARCHAR(50)); INSERT INTO DonorAge (DonorID,DonationYear,DonorAge,DonationAmount,DonationCause) VALUES (1,2022,35,100.00,'Education'),(2,2022,45,200.00,'Health'),(3,2022,32,150.00,'Environment'),(4,2022,38,75.00,'Education'),(5,2022,40,300.00,'Health');
|
SELECT DonationCause, SUM(DonationAmount) as TotalDonations FROM DonorAge WHERE DonationYear = 2022 AND DonorAge BETWEEN 30 AND 40 GROUP BY DonationCause ORDER BY TotalDonations DESC;
|
What is the average economic impact of cultural events in Canada?
|
CREATE TABLE countries (country_id INT,country TEXT); INSERT INTO countries (country_id,country) VALUES (1,'Canada'); CREATE TABLE cultural_events (event_id INT,country_id INT,economic_impact FLOAT); INSERT INTO cultural_events (event_id,country_id,economic_impact) VALUES (1,1,200.0),(2,1,250.0),(3,1,300.0);
|
SELECT AVG(economic_impact) FROM cultural_events WHERE country_id = (SELECT country_id FROM countries WHERE country = 'Canada');
|
What is the name and age of the oldest editor in the 'editors' table?
|
CREATE TABLE editors (id INT,name VARCHAR(50),gender VARCHAR(10),age INT,experience INT); INSERT INTO editors (id,name,gender,age,experience) VALUES (1,'John Doe','Male',55,15); INSERT INTO editors (id,name,gender,age,experience) VALUES (2,'Jim Brown','Male',50,12); INSERT INTO editors (id,name,gender,age,experience) VALUES (3,'Samantha Johnson','Female',45,10); INSERT INTO editors (id,name,gender,age,experience) VALUES (4,'Alicia Keys','Female',40,8);
|
SELECT name, age FROM editors ORDER BY age DESC LIMIT 1;
|
Identify the most common media representation issue in the past month.
|
CREATE TABLE RepresentationIssues (ID INT,Issue TEXT,Date DATE); INSERT INTO RepresentationIssues (ID,Issue,Date) VALUES (1,'Gender','2022-01-01'),(2,'Race','2022-01-05'),(3,'Gender','2022-01-07');
|
SELECT Issue, COUNT(*) as Count FROM RepresentationIssues WHERE Date >= DATEADD(month, -1, CURRENT_DATE) GROUP BY Issue ORDER BY Count DESC LIMIT 1;
|
What is the percentage of smokers in Australia?
|
CREATE TABLE Smoking (Country TEXT,Smokers INT,Total INT); INSERT INTO Smoking (Country,Smokers,Total) VALUES ('Australia',1500,5000),('Australia',2000,5000);
|
SELECT (Smokers / Total) * 100 FROM Smoking WHERE Country = 'Australia';
|
What is the average response time for theft incidents?
|
CREATE TABLE Incidents (id INT PRIMARY KEY,incident_type VARCHAR(50),response_time TIME); INSERT INTO Incidents (id,incident_type,response_time) VALUES (1,'Theft','00:15:00'),(2,'Burglary','00:20:00');
|
SELECT AVG(response_time) FROM Incidents WHERE incident_type = 'Theft';
|
What is the total number of races won by Lewis Hamilton in Formula 1?
|
CREATE TABLE f1_wins (driver VARCHAR(100),races_won INT); INSERT INTO f1_wins (driver,races_won) VALUES ('Lewis Hamilton',103),('Michael Schumacher',91);
|
SELECT SUM(races_won) FROM f1_wins WHERE driver = 'Lewis Hamilton';
|
What is the maximum smart city technology investment for cities with a population greater than 1 million?
|
CREATE TABLE smart_city_investments (id INT,city VARCHAR(255),investment FLOAT); CREATE VIEW city_populations AS SELECT city,population FROM city_data;
|
SELECT city, MAX(investment) FROM smart_city_investments JOIN city_populations ON smart_city_investments.city = city_populations.city WHERE population > 1000000 GROUP BY city;
|
How many startups were founded by people with disabilities?
|
CREATE TABLE startups (id INT,name TEXT,location TEXT,founder_disability BOOLEAN); INSERT INTO startups (id,name,location,founder_disability) VALUES (1,'Startup A','USA',true); INSERT INTO startups (id,name,location,founder_disability) VALUES (2,'Startup B','Canada',false); INSERT INTO startups (id,name,location,founder_disability) VALUES (3,'Startup C','USA',true);
|
SELECT COUNT(*) FROM startups WHERE founder_disability = true;
|
What's the average budget of Bollywood movies released in 2020?
|
CREATE TABLE Movies (title VARCHAR(255),release_year INT,genre VARCHAR(50),budget INT);
|
SELECT AVG(budget) FROM Movies WHERE genre = 'Bollywood' AND release_year = 2020;
|
Display the number of mobile subscribers in each country, excluding those who have had billing issues in the past year.
|
CREATE TABLE MobileSubscribers (SubscriberID int,Country varchar(10),BillingIssue bit); INSERT INTO MobileSubscribers (SubscriberID,Country,BillingIssue) VALUES (1,'USA',0),(2,'Canada',1),(3,'Mexico',0),(4,'Brazil',1),(5,'Argentina',0);
|
SELECT Country, COUNT(*) FROM MobileSubscribers WHERE BillingIssue = 0 GROUP BY Country;
|
Determine the total number of visitors from African countries.
|
CREATE TABLE Visitors (id INT,country VARCHAR(20),visitor_count INT); INSERT INTO Visitors (id,country,visitor_count) VALUES (1,'Egypt',100),(2,'Nigeria',200),(3,'South Africa',150),(4,'USA',250);
|
SELECT SUM(visitor_count) FROM Visitors WHERE country IN ('Egypt', 'Nigeria', 'South Africa');
|
What is the total number of workers employed in factories with a focus on renewable energy?
|
CREATE TABLE factories (factory_id INT,name VARCHAR(100),location VARCHAR(100),renewable_energy_focus BOOLEAN); CREATE TABLE workers (worker_id INT,factory_id INT,name VARCHAR(100),position VARCHAR(100)); INSERT INTO factories (factory_id,name,location,renewable_energy_focus) VALUES (1,'Eco-Friendly Factory','Seattle',TRUE),(2,'Traditional Factory','Chicago',FALSE); INSERT INTO workers (worker_id,factory_id,name,position) VALUES (1,1,'Jamie Lopez','Engineer'),(2,1,'Kevin Nguyen','Operator'),(3,2,'Aisha Patel','Manager'),(4,2,'Liam Kim','Engineer');
|
SELECT COUNT(workers.worker_id) FROM factories INNER JOIN workers ON factories.factory_id = workers.factory_id WHERE factories.renewable_energy_focus = TRUE;
|
What is the maximum emission quantity for each emission type in pollution sources that have not been inspected in the last 6 months?
|
CREATE TABLE PollutionSources (id INT,source_name VARCHAR(255),emission_type VARCHAR(255),emission_quantity INT,last_inspection DATE);
|
SELECT emission_type, MAX(emission_quantity) FROM PollutionSources WHERE last_inspection <= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) GROUP BY emission_type;
|
List all public works projects with their respective design standards.
|
CREATE TABLE PublicWorks (ProjectID int,Name varchar(50)); CREATE TABLE DesignStandards (StandardID int,ProjectID int,Description varchar(50)); INSERT INTO PublicWorks (ProjectID,Name) VALUES (1,'Road Reconstruction'),(2,'Bridge Building'); INSERT INTO DesignStandards (StandardID,ProjectID,Description) VALUES (101,1,'AASHTO 2010'),(102,1,'City of Seattle 2015'),(201,2,'AASHTO 2017');
|
SELECT PublicWorks.Name, DesignStandards.Description FROM PublicWorks INNER JOIN DesignStandards ON PublicWorks.ProjectID = DesignStandards.ProjectID;
|
What is the rank of defense diplomacy events by country based on frequency?
|
CREATE TABLE DiplomacyEvents(Country NVARCHAR(50),EventType VARCHAR(50),Year INT);INSERT INTO DiplomacyEvents(Country,EventType,Year) VALUES ('United States','Military Exercise',2010),('China','Military Exercise',2010),('United States','Military Exercise',2011),('China','Military Exercise',2011),('United States','Defense Talks',2010),('China','Defense Talks',2010),('United States','Joint Military Training',2011),('China','Joint Military Training',2011);
|
SELECT Country, RANK() OVER(ORDER BY COUNT(*) DESC) AS Event_Rank FROM DiplomacyEvents WHERE EventType = 'Military Exercise' OR EventType = 'Defense Talks' OR EventType = 'Joint Military Training' GROUP BY Country;
|
What is the earliest launch date for each spacecraft manufacturer?
|
CREATE TABLE spacecraft_manufacturing (id INT,manufacturer VARCHAR,spacecraft VARCHAR,launch_date DATE);
|
SELECT manufacturer, MIN(launch_date) as earliest_launch_date FROM spacecraft_manufacturing GROUP BY manufacturer;
|
What is the total number of scientific discoveries made by private space companies?
|
CREATE TABLE discoveries (id INT,name VARCHAR(255),company VARCHAR(255),year INT); INSERT INTO discoveries (id,name,company,year) VALUES (1,'Discovery1','SpaceX',2021); INSERT INTO discoveries (id,name,company,year) VALUES (2,'Discovery2','Blue Origin',2022);
|
SELECT COUNT(*) FROM discoveries WHERE company IN ('SpaceX', 'Blue Origin');
|
How many unique genres of songs were released before 1990?
|
CREATE TABLE songs (song_id INT,title VARCHAR(255),release_year INT,genre VARCHAR(50),length FLOAT); INSERT INTO songs (song_id,title,release_year,genre,length) VALUES (1,'Song1',1985,'classical',120.5),(2,'Song2',1988,'jazz',210.3),(3,'Song3',1975,'rock',180.7),(4,'Song4',1989,'classical',200.0);
|
SELECT COUNT(DISTINCT genre) FROM songs WHERE release_year < 1990;
|
Rank the mental health conditions by the number of patients treated.
|
CREATE TABLE conditions (condition_id INT,condition VARCHAR(50)); INSERT INTO conditions (condition_id,condition) VALUES (1,'Depression'),(2,'Anxiety'),(3,'Bipolar Disorder'); CREATE TABLE patients (patient_id INT,condition_id INT); INSERT INTO patients (patient_id,condition_id) VALUES (1,1),(2,2),(3,2),(4,3),(5,1);
|
SELECT conditions.condition, ROW_NUMBER() OVER(ORDER BY COUNT(patients.condition_id) DESC) AS rank FROM conditions INNER JOIN patients ON conditions.condition_id = patients.condition_id GROUP BY conditions.condition;
|
What is the market share of natural cosmetics in the Canadian market?
|
CREATE TABLE ProductInventory (product_id INT,product_name TEXT,category TEXT,is_natural BOOLEAN,country TEXT); CREATE VIEW CanadianNaturalCosmetics AS SELECT * FROM ProductInventory WHERE category = 'cosmetics' AND is_natural = TRUE AND country = 'Canada';
|
SELECT 100.0 * COUNT(*) / (SELECT COUNT(*) FROM ProductInventory WHERE country = 'Canada') as market_share FROM CanadianNaturalCosmetics;
|
How many hospitals are there in each state of the United States?
|
CREATE TABLE hospitals (id INT,state VARCHAR(20),name VARCHAR(30)); INSERT INTO hospitals (id,state,name) VALUES (1,'California','Hospital A'),(2,'California','Hospital B'),(3,'Texas','Hospital C');
|
SELECT state, COUNT(*) FROM hospitals GROUP BY state;
|
What is the total production volume of uranium in Canada for the year 2019?
|
CREATE TABLE production (id INT,mine_id INT,year INT,product TEXT,production_volume INT); INSERT INTO production (id,mine_id,year,product,production_volume) VALUES (1,1,2019,'Uranium',5000);
|
SELECT SUM(production_volume) FROM production WHERE year = 2019 AND product = 'Uranium' AND mine_id IN (SELECT id FROM mines WHERE location = 'Canada');
|
What is the average salary of full-time employees by gender in the mining industry?
|
CREATE TABLE miners (id INT,gender TEXT,is_full_time BOOLEAN,salary FLOAT); INSERT INTO miners (id,gender,is_full_time,salary) VALUES (1,'Male',TRUE,75000.0),(2,'Female',TRUE,72000.0);
|
SELECT gender, AVG(salary) FROM miners WHERE is_full_time = TRUE GROUP BY gender;
|
How many wells were drilled in the 'Barents Sea' from 2015 to 2019?
|
CREATE TABLE wells (well_id INT,field VARCHAR(50),region VARCHAR(50),drill_year INT,production_oil FLOAT,production_gas FLOAT); INSERT INTO wells (well_id,field,region,drill_year,production_oil,production_gas) VALUES (1,'Snøhvit','Barents Sea',2016,15000.0,5000.0),(2,'Goliat','Barents Sea',2017,8000.0,6000.0);
|
SELECT COUNT(*) FROM wells WHERE region = 'Barents Sea' AND drill_year BETWEEN 2015 AND 2019;
|
What is the number of graduate students in each department who are international students?
|
CREATE TABLE department (id INT,name TEXT); CREATE TABLE graduate_students (id INT,department_id INT,is_international_student BOOLEAN);
|
SELECT d.name, COUNT(gs.id) FROM department d JOIN graduate_students gs ON d.id = gs.department_id WHERE gs.is_international_student = TRUE GROUP BY d.name;
|
Increase the temperature sensor readings by 2 degrees Celsius where the sensor_id is 5
|
CREATE TABLE temperature_sensor_data (sensor_id INT,temperature FLOAT,timestamp TIMESTAMP); INSERT INTO temperature_sensor_data (sensor_id,temperature,timestamp) VALUES (4,27.3,'2021-01-01 10:00:00'),(5,26.2,'2021-01-01 10:00:00'),(6,28.1,'2021-01-01 10:00:00');
|
WITH updated_data AS (UPDATE temperature_sensor_data SET temperature = temperature + 2 WHERE sensor_id = 5 RETURNING *) SELECT * FROM updated_data;
|
List all communities that have both eco-friendly and inclusive housing policies.
|
CREATE TABLE communities (community VARCHAR(255),eco_friendly BOOLEAN,inclusive_policy BOOLEAN); INSERT INTO communities (community,eco_friendly,inclusive_policy) VALUES ('CommunityA',true,true),('CommunityB',false,true),('CommunityC',true,false);
|
SELECT community FROM communities WHERE eco_friendly = true AND inclusive_policy = true;
|
Insert a new record into the "media_ethics" table with "principle" as "Independence", "description" as "Journalists should maintain independence from those they cover"
|
CREATE TABLE media_ethics (id INT PRIMARY KEY,principle VARCHAR(255),description TEXT,example TEXT);
|
INSERT INTO media_ethics (principle, description) VALUES ('Independence', 'Journalists should maintain independence from those they cover');
|
What was the maximum energy efficiency rating of appliances sold in India and China in 2021?
|
CREATE TABLE appliance_efficiency (id INT,country VARCHAR(255),year INT,efficiency_rating INT); INSERT INTO appliance_efficiency (id,country,year,efficiency_rating) VALUES (1,'India',2021,5),(2,'China',2021,6);
|
SELECT MAX(efficiency_rating) FROM appliance_efficiency WHERE country IN ('India', 'China') AND year = 2021;
|
What is the average occupancy rate of virtual tourism experiences in New Zealand?
|
CREATE TABLE virtual_experiences (experience_id INT,experience_name TEXT,country TEXT,occupancy_rate FLOAT); INSERT INTO virtual_experiences (experience_id,experience_name,country,occupancy_rate) VALUES (1,'Virtual Hobbiton Tour','New Zealand',0.75); INSERT INTO virtual_experiences (experience_id,experience_name,country,occupancy_rate) VALUES (2,'Virtual Milford Sound Tour','New Zealand',0.85);
|
SELECT AVG(occupancy_rate) FROM virtual_experiences WHERE country = 'New Zealand';
|
What is the total revenue generated from sales in each region in the last quarter?
|
CREATE TABLE sales (sale_id int,sale_region varchar(50),sale_date date,revenue int);
|
SELECT sale_region, SUM(revenue) as total_revenue FROM sales WHERE sale_date >= DATEADD(quarter, -1, GETDATE()) GROUP BY sale_region;
|
Find the total number of followers for users who have posted at least once about "renewable_energy" in the "eco_influencers" table.
|
CREATE TABLE eco_influencers (id INT,username TEXT,posts TEXT,followers INT);
|
SELECT SUM(followers) FROM eco_influencers WHERE posts LIKE '%renewable_energy%' HAVING COUNT(*) >= 1;
|
What is the average price of vegetarian dishes offered by local vendors?
|
CREATE TABLE Vendors (VendorID INT,Name VARCHAR(50),Type VARCHAR(50)); INSERT INTO Vendors (VendorID,Name,Type) VALUES (1,'GreenTruck','Local'); CREATE TABLE Menu (MenuID INT,Name VARCHAR(50),Type VARCHAR(50),Price DECIMAL(5,2)); INSERT INTO Menu (MenuID,Name,Type,Price) VALUES (1,'Veggie Burger','Vegetarian',7.50),(2,'Falafel Wrap','Vegetarian',6.99);
|
SELECT AVG(Price) FROM Menu INNER JOIN Vendors ON Menu.VendorID = Vendors.VendorID WHERE Menu.Type = 'Vegetarian' AND Vendors.Type = 'Local';
|
How many labor violations have been reported in each country for the past year?
|
CREATE TABLE Labor_Violations (violation_id INT,country VARCHAR(50),violation_date DATE);
|
SELECT Labor_Violations.country, COUNT(*) as total_violations FROM Labor_Violations WHERE violation_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY Labor_Violations.country;
|
What is the total number of wildlife habitats for the entire dataset?
|
CREATE TABLE wildlife_habitat(type VARCHAR(255),count INT); INSERT INTO wildlife_habitat(type,count) VALUES ('Forest',300),('Wetland',200),('Grassland',150),('Desert',50);
|
SELECT SUM(count) FROM wildlife_habitat;
|
What is the total number of marine species found in the Arctic ocean?'
|
CREATE TABLE marine_species (species_id INT,name VARCHAR(50),ocean VARCHAR(50),population INT);
|
SELECT SUM(population) AS total_species FROM marine_species WHERE ocean = 'Arctic';
|
What is the total revenue for 'Cuisine Type A' dishes?
|
CREATE TABLE Restaurants (id INT,name VARCHAR(255),cuisine_type VARCHAR(255)); INSERT INTO Restaurants (id,name,cuisine_type) VALUES (1,'Restaurant A','Cuisine Type A'),(2,'Restaurant B','Cuisine Type B');
|
SELECT SUM(revenue) FROM Sales WHERE dish_type = (SELECT id FROM Restaurants WHERE cuisine_type = 'Cuisine Type A');
|
Find the total number of hotel listings in Europe and Asia, excluding duplicates.
|
CREATE TABLE hotel_listings (hotel_id INT,location VARCHAR(20)); INSERT INTO hotel_listings (hotel_id,location) VALUES (1,'Paris'),(2,'Berlin'),(3,'Tokyo');
|
SELECT location, COUNT(DISTINCT hotel_id) as total_hotels FROM hotel_listings WHERE location IN ('Europe', 'Asia') GROUP BY location
|
Calculate the average time to resolution for cases in the civil division
|
CREATE TABLE cases (case_id INT,division VARCHAR(50),resolution_time INT); INSERT INTO cases (case_id,division,resolution_time) VALUES (1,'civil',60),(2,'criminal',90),(3,'civil',45),(4,'criminal',75);
|
SELECT AVG(resolution_time) FROM cases WHERE division = 'civil';
|
What is the total number of construction projects in Colorado that were completed in the past year?
|
CREATE TABLE Projects (ProjectID int,ProjectName varchar(255),State varchar(255),StartDate date,EndDate date,IsSustainable bit); CREATE TABLE Companies (CompanyID int,CompanyName varchar(255),State varchar(255)); CREATE TABLE LaborCosts (CostID int,ProjectID int,LaborCost money,Date date);
|
SELECT COUNT(ProjectID) as TotalProjects FROM Projects JOIN Companies ON Projects.State = Companies.State WHERE Companies.State = 'Colorado' AND Projects.EndDate >= DATEADD(year, -1, GETDATE());
|
Determine the total amount of research grants awarded to graduate students in the 'grad_students' and 'research_grants' tables
|
CREATE TABLE grad_students (student_id INT,name VARCHAR(50),gender VARCHAR(10),department VARCHAR(50)); CREATE TABLE research_grants (student_id INT,grant_date DATE,grant_amount FLOAT); INSERT INTO grad_students (student_id,name,gender,department) VALUES (1,'John Doe','Male','Computer Science'),(2,'Jane Smith','Female','Physics'),(3,'Alice Johnson','Female','Mathematics'),(4,'Bob Brown','Male','Chemistry'); INSERT INTO research_grants (student_id,grant_date,grant_amount) VALUES (1,'2020-01-01',15000),(2,'2019-08-15',20000),(3,'2020-12-31',12000),(5,'2019-06-12',18000);
|
SELECT SUM(rg.grant_amount) FROM grad_students gs INNER JOIN research_grants rg ON gs.student_id = rg.student_id;
|
Which hotels in the Middle East have adopted the most AI technologies?
|
CREATE TABLE ai_adoption (hotel_id INT,num_ai_technologies INT); INSERT INTO ai_adoption (hotel_id,num_ai_technologies) VALUES (1,3),(2,2),(3,4),(4,1),(5,5); CREATE TABLE hotels (hotel_id INT,hotel_name TEXT,country TEXT); INSERT INTO hotels (hotel_id,hotel_name,country) VALUES (1,'Hotel A','UAE'),(2,'Hotel B','Saudi Arabia'),(3,'Hotel C','Qatar'),(4,'Hotel D','Oman'),(5,'Hotel E','Bahrain');
|
SELECT hotel_name, num_ai_technologies FROM ai_adoption INNER JOIN hotels ON ai_adoption.hotel_id = hotels.hotel_id WHERE country IN ('UAE', 'Saudi Arabia', 'Qatar', 'Oman', 'Bahrain') ORDER BY num_ai_technologies DESC;
|
What is the total number of tickets sold for each event by day of the week?
|
CREATE TABLE event_days (event_day ENUM('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'),event_id INT);
|
SELECT e.event_name, e.event_day, COUNT(t.ticket_id) FROM event_days ed JOIN events e ON ed.event_id = e.event_id JOIN tickets t ON ed.event_day = DAYOFWEEK(t.event_date) JOIN events e ON t.event_id = e.event_id GROUP BY e.event_name, e.event_day;
|
List the top 5 graduate students with the highest number of research publications in the Mathematics department.
|
CREATE TABLE graduate_students (id INT,name VARCHAR(100),department VARCHAR(50),publications INT); INSERT INTO graduate_students (id,name,department,publications) VALUES (1,'Bob','Mathematics',20);
|
SELECT name, department, publications FROM graduate_students WHERE department = 'Mathematics' ORDER BY publications DESC LIMIT 5;
|
List the top 3 countries with the highest seafood production?
|
CREATE TABLE country (id INT,name TEXT,production DECIMAL(15,2)); INSERT INTO country (id,name,production) VALUES (1,'China',55000);
|
SELECT name, production FROM country ORDER BY production DESC LIMIT 3;
|
What is the total number of crimes committed in each category in the last year?
|
CREATE TABLE crime_categories (id INT,name TEXT);CREATE TABLE crimes (id INT,category_id INT,date DATE);
|
SELECT c.name, COUNT(cr.id) FROM crime_categories c JOIN crimes cr ON c.id = cr.category_id WHERE cr.date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY c.id;
|
What are the names of the contractors who have completed at least one sustainable building project?
|
CREATE TABLE Contractors (ContractorID INT,ContractorName TEXT); INSERT INTO Contractors (ContractorID,ContractorName) VALUES (1,'ABC Builders'),(2,'Green Construction'); CREATE TABLE SustainableProjects (ProjectID INT,ContractorID INT); INSERT INTO SustainableProjects (ProjectID,ContractorID) VALUES (101,1),(102,2),(103,1);
|
SELECT ContractorName FROM Contractors C INNER JOIN SustainableProjects SP ON C.ContractorID = SP.ContractorID GROUP BY ContractorName;
|
What is the total number of AI safety incidents reported in 2020 and 2021, grouped by the quarter in which they occurred?
|
CREATE TABLE ai_safety_incidents (incident_id INT,incident_date DATE,ai_subfield TEXT,incident_description TEXT); INSERT INTO ai_safety_incidents (incident_id,incident_date,ai_subfield,incident_description) VALUES (1,'2020-01-01','Explainable AI','Model failed to provide clear explanations'); INSERT INTO ai_safety_incidents (incident_id,incident_date,ai_subfield,incident_description) VALUES (2,'2019-12-31','Algorithmic Fairness','AI system showed bias against certain groups'); INSERT INTO ai_safety_incidents (incident_id,incident_date,ai_subfield,incident_description) VALUES (3,'2020-02-01','Explainable AI','Model provided inconsistent explanations');
|
SELECT DATE_PART('quarter', incident_date) as quarter, COUNT(*) as incidents FROM ai_safety_incidents WHERE incident_date BETWEEN '2020-01-01' AND '2021-12-31' GROUP BY quarter;
|
Update the region for the record with id 1 in the pollution_sources table to 'Atlantic Ocean'.
|
CREATE TABLE pollution_sources (id INT,name VARCHAR(255),region VARCHAR(255)); INSERT INTO pollution_sources (id,name,region) VALUES (1,'Oceanic Chemical Pollution','Pacific Ocean');
|
UPDATE pollution_sources SET region = 'Atlantic Ocean' WHERE id = 1;
|
What is the average rating for public safety and waste management in CityX?
|
CREATE TABLE Feedback (City VARCHAR(20),Category VARCHAR(20),Rating INT); INSERT INTO Feedback (City,Category,Rating) VALUES ('CityX','Public Safety',7); INSERT INTO Feedback (City,Category,Rating) VALUES ('CityX','Waste Management',8);
|
SELECT City, AVG(CASE WHEN Category = 'Public Safety' THEN Rating ELSE 0 END) AS 'Public Safety Avg Rating', AVG(CASE WHEN Category = 'Waste Management' THEN Rating ELSE 0 END) AS 'Waste Management Avg Rating' FROM Feedback WHERE City = 'CityX' GROUP BY City;
|
How many cultural heritage sites are registered in Tokyo and Osaka?
|
CREATE TABLE cultural_sites (site_id INT,name TEXT,city TEXT); INSERT INTO cultural_sites (site_id,name,city) VALUES (1,'Tsukiji Fish Market','Tokyo'),(2,'Sensoji Temple','Tokyo'),(3,'Osaka Castle','Osaka');
|
SELECT COUNT(*) FROM cultural_sites WHERE city IN ('Tokyo', 'Osaka');
|
How many offshore drilling platforms were there in the Caspian Sea as of 2019?
|
CREATE TABLE caspian_sea_platforms (year INT,region VARCHAR(20),num_platforms INT); INSERT INTO caspian_sea_platforms (year,region,num_platforms) VALUES (2015,'Caspian Sea',1200),(2016,'Caspian Sea',1250),(2017,'Caspian Sea',1300),(2018,'Caspian Sea',1350),(2019,'Caspian Sea',1400),(2020,'Caspian Sea',1450);
|
SELECT num_platforms FROM caspian_sea_platforms WHERE year = 2019 AND region = 'Caspian Sea';
|
What is the total mass of all asteroids researched by a specific team of astrophysicists?
|
CREATE TABLE Astrophysicists (id INT,name TEXT,team TEXT); CREATE TABLE Asteroids (id INT,astrophysicist_id INT,name TEXT,mass FLOAT);
|
SELECT SUM(mass) FROM Asteroids WHERE astrophysicist_id IN (SELECT id FROM Astrophysicists WHERE team = 'TeamX');
|
List the unique names of all satellites owned by Japan and South Korea?
|
CREATE TABLE satellites (satellite_id INT,name VARCHAR(100),owner_country VARCHAR(50)); INSERT INTO satellites (satellite_id,name,owner_country) VALUES (1,'Japanese Earth Resource Satellite','Japan'),(2,'South Korean Communication Satellite','South Korea');
|
SELECT DISTINCT name FROM satellites WHERE owner_country IN ('Japan', 'South Korea');
|
What is the average budget allocated for accessible technology projects per year?
|
CREATE TABLE budgets(id INT,project TEXT,year INT,amount FLOAT); INSERT INTO budgets(id,project,year,amount) VALUES (1,'Accessible Tech',2021,100000.0); INSERT INTO budgets(id,project,year,amount) VALUES (2,'Accessible Tech',2022,120000.0); INSERT INTO budgets(id,project,year,amount) VALUES (3,'Digital Divide',2021,150000.0);
|
SELECT AVG(amount) FROM budgets WHERE project = 'Accessible Tech' GROUP BY year;
|
Add a new community education program to the database
|
CREATE TABLE community_education (program_id INT,program_name VARCHAR(50),target_audience VARCHAR(50),instructor_name VARCHAR(50));
|
INSERT INTO community_education (program_id, program_name, target_audience, instructor_name) VALUES (4, 'Wildlife Art', 'Children (8-12)', 'Jamila Thompson');
|
What is the minimum approval date for drugs approved for pediatric use?
|
CREATE TABLE drug_approval (drug_name TEXT,approval_date DATE); INSERT INTO drug_approval (drug_name,approval_date) VALUES ('DrugA','2018-01-01'),('DrugB','2017-05-15'),('DrugC','2020-09-27'),('DrugD','2016-08-04');
|
SELECT MIN(approval_date) FROM drug_approval WHERE drug_name IN (SELECT drug_name FROM drug_approval WHERE approval_date >= DATE('now', '-5 year'));
|
How many artifacts were made of metal, per site?
|
CREATE TABLE artifact_details (id INT,artifact_id INT,artifact_type VARCHAR(50),weight INT);
|
SELECT site_name, SUM(CASE WHEN artifact_type = 'metal' THEN 1 ELSE 0 END) as metal_artifacts FROM excavation_sites
|
What is the minimum production in 'FieldG' for each month of 2019?
|
CREATE TABLE wells (well_id varchar(10),field varchar(10),production int,datetime date); INSERT INTO wells (well_id,field,production,datetime) VALUES ('W007','FieldG',1500,'2019-01-01'),('W008','FieldG',1600,'2019-01-15');
|
SELECT field, YEAR(datetime) AS year, MONTH(datetime) AS month, MIN(production) AS min_production FROM wells WHERE field = 'FieldG' GROUP BY field, year, month;
|
Who are the top 3 actors with the highest average rating?
|
CREATE TABLE Ratings (id INT,actor_id INT,movie_id INT,rating DECIMAL(3,2)); INSERT INTO Ratings (id,actor_id,movie_id,rating) VALUES (1,1,1,8.5),(2,2,2,7.8),(3,3,3,9.0),(4,1,4,8.8); CREATE TABLE Actors (id INT,name VARCHAR(255)); INSERT INTO Actors (id,name) VALUES (1,'Actor1'),(2,'Actor2'),(3,'Actor3'),(4,'Actor4');
|
SELECT a.name, AVG(r.rating) FROM Actors a JOIN Ratings r ON a.id = r.actor_id GROUP BY a.name ORDER BY AVG(r.rating) DESC LIMIT 3;
|
What is the total cost of space missions by agency?
|
CREATE TABLE space_agency_missions (id INT,agency VARCHAR(50),name VARCHAR(50),cost INT); INSERT INTO space_agency_missions (id,agency,name,cost) VALUES (1,'NASA','Mars Rover 2001',2500000),(2,'NASA','ISS',150000000),(3,'ESA','Hubble Space Telescope',1000000000);
|
SELECT agency, SUM(cost) FROM space_agency_missions GROUP BY agency;
|
Find the name and description of the model with the highest accuracy in the 'model_performance' table.
|
CREATE TABLE model_performance (model_name TEXT,accuracy FLOAT); INSERT INTO model_performance (model_name,accuracy) VALUES ('modelA',0.92),('modelB',0.88),('modelC',0.95);
|
SELECT model_name, accuracy FROM model_performance ORDER BY accuracy DESC LIMIT 1;
|
What is the average stream count for songs released in 2020?
|
CREATE TABLE song_streams (song_id INT,artist_name VARCHAR(30),release_year INT,stream_count INT); INSERT INTO song_streams (song_id,artist_name,release_year,stream_count) VALUES (1,'Taylor Swift',2020,100000),(2,'BTS',2020,125000),(3,'Kendrick Lamar',2019,75000),(4,'Ariana Grande',2020,110000);
|
SELECT release_year, AVG(stream_count) as avg_stream_count FROM song_streams WHERE release_year = 2020 GROUP BY release_year;
|
List the top 3 aquaculture farms with the highest water temperature?
|
CREATE TABLE Farm (FarmID INT,FarmName VARCHAR(255),WaterTemperature DECIMAL(5,2)); INSERT INTO Farm (FarmID,FarmName,WaterTemperature) VALUES (1,'Farm A',28.5),(2,'Farm B',12.3),(3,'Farm C',30.0),(4,'Farm D',29.5),(5,'Farm E',24.2);
|
SELECT FarmName, WaterTemperature, ROW_NUMBER() OVER (ORDER BY WaterTemperature DESC) as Rank FROM Farm WHERE Rank <= 3;
|
How many buses in the 'Westpoint' region have a fare greater than 2.00?
|
CREATE TABLE Buses (route_id INT,region VARCHAR(20),fare DECIMAL(5,2)); INSERT INTO Buses (route_id,region,fare) VALUES (1,'Westpoint',1.50),(2,'Westpoint',2.50),(3,'Westpoint',3.00);
|
SELECT COUNT(*) FROM Buses WHERE region = 'Westpoint' AND fare > 2.00;
|
List the names and education programs of all coordinators in the 'Africa' region.
|
CREATE TABLE Coordinators (id INT,name VARCHAR(20),region VARCHAR(20)); INSERT INTO Coordinators (id,name,region) VALUES (1,'John Doe','Africa'),(2,'Jane Smith','Asia'),(3,'Alice Johnson','Africa'); CREATE TABLE EducationPrograms (id INT,coordinator_id INT,name VARCHAR(20)); INSERT INTO EducationPrograms (id,coordinator_id,name) VALUES (1,1,'Save the Lions'),(2,2,'Protect the Elephants'),(3,3,'Giraffe Conservation');
|
SELECT c.name, e.name FROM Coordinators c INNER JOIN EducationPrograms e ON c.id = e.coordinator_id WHERE c.region = 'Africa';
|
What is the average age of players who have participated in esports events, categorized by the platform (PC, Console, Mobile)?
|
CREATE TABLE Players (PlayerID INT,Age INT,Platform VARCHAR(10)); INSERT INTO Players (PlayerID,Age,Platform) VALUES (1,25,'PC'),(2,30,'Console'),(3,20,'Mobile'); CREATE TABLE EsportsEvents (EventID INT,PlayerID INT); INSERT INTO EsportsEvents (EventID,PlayerID) VALUES (1,1),(2,2),(3,3);
|
SELECT Platform, AVG(Age) as AvgAge FROM Players p JOIN EsportsEvents e ON p.PlayerID = e.PlayerID GROUP BY Platform;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.