ajayk007/querysmith-spider-bird huggingface dataset:
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
CREATE TABLE Episode (
  episode_id text PRIMARY KEY,
  season integer,
  episode integer,
  number_in_series integer,
  title text,
  summary text,
  air_date text,
  episode_image text,
  rating real,
  votes integer
);
CREATE TABLE Person (
  name text PRIMARY KEY,
  birthdate text,
  birth_name text,
  birth_place text,
  birth_region text,
  birth_country text,
  height_meters real,
  nickname text
);
CREATE TABLE Award (
  award_id integer PRIMARY KEY,
  organization text,
  year integer,
  award_category text,
  award text,
  person text,
  role text,
  episode_id text,
  season text,
  song text,
  result text
);
CREATE TABLE Character_Award (
  award_id integer,
  character text
);
CREATE TABLE Credit (
  episode_id text,
  category text,
  person text,
  role text,
  credited text
);
CREATE TABLE Keyword (
  episode_id text PRIMARY KEY,
  keyword text PRIMARY KEY
);
CREATE TABLE Vote (
  episode_id text,
  stars integer,
  votes integer,
  percent real
);
-- foreign keys: Award.episode_id -> Episode.episode_id; Award.person -> Person.name; Character_Award.award_id -> Award.award_id; Credit.person -> Person.name; Credit.episode_id -> Episode.episode_id; Keyword.episode_id -> Episode.episode_id; Vote.episode_id -> Episode.episode_id

Hint: "Matt Groening" is the person; 'In the Name of the Grandfather' is the title of episode; episode number refers to episode; series number refers to number_in_series

Question: List down all the roles of Matt Groening on the episode titled 'In the Name of the Grandfather' along with the episode number and series number.

assistant: SELECT T2.role, T1.episode, T1.number_in_series FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id WHERE T2.person = 'Matt Groening' AND T1.title = 'In the Name of the Grandfather';
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
create table Allergy_Type (
       Allergy 		  VARCHAR(20) PRIMARY KEY,
       AllergyType 	  VARCHAR(20)
);

create table Has_Allergy (
       StuID 		 INTEGER,
       Allergy 		 VARCHAR(20),
       FOREIGN KEY(StuID) REFERENCES Student(StuID),
       FOREIGN KEY(Allergy) REFERENCES Allergy_Type(Allergy)
);

create table Student (
        StuID        INTEGER PRIMARY KEY,
        LName        VARCHAR(12),
        Fname        VARCHAR(12),
        Age      INTEGER,
        Sex      VARCHAR(1),
        Major        INTEGER,
        Advisor      INTEGER,
        city_code    VARCHAR(3)
 );

Question: Which allergy has most number of students affected?

assistant: SELECT Allergy FROM Has_allergy GROUP BY Allergy ORDER BY count(*) DESC LIMIT 1
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
CREATE TABLE Attributes (
  attribute_id integer PRIMARY KEY,
  attribute_name text
);
CREATE TABLE Categories (
  category_id integer PRIMARY KEY,
  category_name text
);
CREATE TABLE Compliments (
  compliment_id integer PRIMARY KEY,
  compliment_type text
);
CREATE TABLE Days (
  day_id integer PRIMARY KEY,
  day_of_week text
);
CREATE TABLE Years (
  year_id integer PRIMARY KEY,
  actual_year integer
);
CREATE TABLE Business_Attributes (
  attribute_id integer PRIMARY KEY,
  business_id integer PRIMARY KEY,
  attribute_value text
);
CREATE TABLE Business_Categories (
  business_id integer PRIMARY KEY,
  category_id integer PRIMARY KEY
);
CREATE TABLE Business_Hours (
  business_id integer PRIMARY KEY,
  day_id integer PRIMARY KEY,
  opening_time text,
  closing_time text
);
CREATE TABLE Checkins (
  business_id integer PRIMARY KEY,
  day_id integer PRIMARY KEY,
  label_time_0 text,
  label_time_1 text,
  label_time_2 text,
  label_time_3 text,
  label_time_4 text,
  label_time_5 text,
  label_time_6 text,
  label_time_7 text,
  label_time_8 text,
  label_time_9 text,
  label_time_10 text,
  label_time_11 text,
  label_time_12 text,
  label_time_13 text,
  label_time_14 text,
  label_time_15 text,
  label_time_16 text,
  label_time_17 text,
  label_time_18 text,
  label_time_19 text,
  label_time_20 text,
  label_time_21 text,
  label_time_22 text,
  label_time_23 text
);
CREATE TABLE Elite (
  user_id integer PRIMARY KEY,
  year_id integer PRIMARY KEY
);
CREATE TABLE Reviews (
  business_id integer PRIMARY KEY,
  user_id integer PRIMARY KEY,
  review_stars integer,
  review_votes_funny text,
  review_votes_useful text,
  review_votes_cool text,
  review_length text
);
CREATE TABLE Tips (
  business_id integer PRIMARY KEY,
  user_id integer PRIMARY KEY,
  likes integer,
  tip_length text
);
CREATE TABLE Users_Compliments (
  compliment_id integer PRIMARY KEY,
  user_id integer PRIMARY KEY,
  number_of_compliments text
);
CREATE TABLE Business (
  business_id integer PRIMARY KEY,
  active text,
  city text,
  state text,
  stars real,
  review_count text
);
CREATE TABLE Users (
  user_id integer PRIMARY KEY,
  user_yelping_since_year integer,
  user_average_stars text,
  user_votes_funny text,
  user_votes_useful text,
  user_votes_cool text,
  user_review_count text,
  user_fans text
);

Hint: Glendale is a city; the highest star rating refers to MAX(stars)

Question: What is the closing and opening time of businesses located at Glendale with highest star rating?

assistant: SELECT T2.opening_time, T2.closing_time FROM Business AS T1 INNER JOIN Business_Hours AS T2 ON T1.business_id = T2.business_id WHERE T1.city = 'Glendale' ORDER BY T1.stars DESC LIMIT 1
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
CREATE TABLE people (
  Customer ID text PRIMARY KEY,
  Customer Name text,
  Segment text,
  Country text,
  City text,
  State text,
  Postal Code integer,
  Region text PRIMARY KEY
);
CREATE TABLE product (
  Product ID text PRIMARY KEY,
  Product Name text,
  Category text,
  Sub-Category text,
  Region text PRIMARY KEY
);
CREATE TABLE central_superstore (
  Row ID integer PRIMARY KEY,
  Order ID text,
  Order Date date,
  Ship Date date,
  Ship Mode text,
  Customer ID text,
  Region text,
  Product ID text,
  Sales real,
  Quantity integer,
  Discount real,
  Profit real
);
CREATE TABLE east_superstore (
  Row ID integer PRIMARY KEY,
  Order ID text,
  Order Date date,
  Ship Date date,
  Ship Mode text,
  Customer ID text,
  Region text,
  Product ID text,
  Sales real,
  Quantity integer,
  Discount real,
  Profit real
);
CREATE TABLE south_superstore (
  Row ID integer PRIMARY KEY,
  Order ID text,
  Order Date date,
  Ship Date date,
  Ship Mode text,
  Customer ID text,
  Region text,
  Product ID text,
  Sales real,
  Quantity integer,
  Discount real,
  Profit real
);
CREATE TABLE west_superstore (
  Row ID integer PRIMARY KEY,
  Order ID text,
  Order Date date,
  Ship Date date,
  Ship Mode text,
  Customer ID text,
  Region text,
  Product ID text,
  Sales real,
  Quantity integer,
  Discount real,
  Profit real
);
-- foreign keys: central_superstore.Product ID -> product.Product ID; central_superstore.Region -> product.Region; central_superstore.Customer ID -> people.Customer ID; central_superstore.Region -> people.Region; east_superstore.Product ID -> product.Product ID; east_superstore.Region -> product.Region; east_superstore.Customer ID -> people.Customer ID; east_superstore.Region -> people.Region; south_superstore.Product ID -> product.Product ID; south_superstore.Region -> product.Region; south_superstore.Customer ID -> people.Customer ID; south_superstore.Region -> people.Region; west_superstore.Product ID -> product.Product ID; west_superstore.Region -> product.Region; west_superstore.Customer ID -> people.Customer ID; west_superstore.Region -> people.Region

Hint: shipped on 3/25/2015 refers to "Ship Date" = Date('2015-03-25');

Question: How much is the total quantity of items from the East region shipped on 3/25/2015? Name the products.

assistant: SELECT SUM(T1.Quantity), T2.`Product Name` FROM east_superstore AS T1 INNER JOIN product AS T2 ON T1.`Product ID` = T2.`Product ID` WHERE T1.`Ship Date` = '2015-03-25' AND T2.Region = 'East'
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
CREATE TABLE city (
  city_id integer PRIMARY KEY,
  city_name text,
  state text,
  population integer,
  area real
);
CREATE TABLE customer (
  cust_id integer PRIMARY KEY,
  cust_name text,
  annual_revenue integer,
  cust_type text,
  address text,
  city text,
  state text,
  zip real,
  phone text
);
CREATE TABLE driver (
  driver_id integer PRIMARY KEY,
  first_name text,
  last_name text,
  address text,
  city text,
  state text,
  zip_code integer,
  phone text
);
CREATE TABLE truck (
  truck_id integer PRIMARY KEY,
  make text,
  model_year integer
);
CREATE TABLE shipment (
  ship_id integer PRIMARY KEY,
  cust_id integer,
  weight real,
  truck_id integer,
  driver_id integer,
  city_id integer,
  ship_date text
);
-- foreign keys: shipment.truck_id -> truck.truck_id; shipment.driver_id -> driver.driver_id; shipment.city_id -> city.city_id; shipment.cust_id -> customer.cust_id

Hint: heaviest shipment refers to Max(weight); city refers to city_name

Question: In which city did the heaviest shipment transported?

assistant: SELECT T2.city_name FROM shipment AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.city_id ORDER BY T1.weight DESC LIMIT 1
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
-- drop table flight cascade constraints;
-- drop table aircraft cascade constraints;
-- drop table employee cascade constraints;
-- drop table certificate cascade constraints;

create table flight(
	flno number(4,0) primary key,
	origin varchar2(20),
	destination varchar2(20),
	distance number(6,0),
	departure_date date,
	arrival_date date,
	price number(7,2),
    aid number(9,0),
    foreign key("aid") references `aircraft`("aid"));

create table aircraft(
	aid number(9,0) primary key,
	name varchar2(30),
	distance number(6,0));

create table employee(
	eid number(9,0) primary key,
	name varchar2(30),
	salary number(10,2));

create table certificate(
	eid number(9,0),
	aid number(9,0),
	primary key(eid,aid),
	foreign key("eid") references `employee`("eid"),
	foreign key("aid") references `aircraft`("aid"));

Question: Show all destinations and the number of flights to each destination.

assistant: SELECT destination , count(*) FROM Flight GROUP BY destination
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
CREATE TABLE country (
  origin integer PRIMARY KEY,
  country text
);
CREATE TABLE price (
  ID integer PRIMARY KEY,
  price real
);
CREATE TABLE data (
  ID integer PRIMARY KEY,
  mpg real,
  cylinders integer,
  displacement real,
  horsepower integer,
  weight integer,
  acceleration real,
  model integer,
  car_name text
);
CREATE TABLE production (
  ID integer PRIMARY KEY,
  model_year integer PRIMARY KEY,
  country integer
);
-- foreign keys: data.ID -> price.ID; production.ID -> price.ID; production.ID -> data.ID; production.country -> country.origin

Hint: year refers to model_year; Europe refers to country = 'Europe'; the most cars refers to max(model_year)

Question: Which year did Europe produce the most cars?

assistant: SELECT T1.model_year FROM production AS T1 INNER JOIN country AS T2 ON T1.country = T2.origin WHERE T2.country = 'Europe' GROUP BY T1.model_year ORDER BY COUNT(T1.model_year) DESC LIMIT 1
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
CREATE TABLE people (
  Customer ID text PRIMARY KEY,
  Customer Name text,
  Segment text,
  Country text,
  City text,
  State text,
  Postal Code integer,
  Region text PRIMARY KEY
);
CREATE TABLE product (
  Product ID text PRIMARY KEY,
  Product Name text,
  Category text,
  Sub-Category text,
  Region text PRIMARY KEY
);
CREATE TABLE central_superstore (
  Row ID integer PRIMARY KEY,
  Order ID text,
  Order Date date,
  Ship Date date,
  Ship Mode text,
  Customer ID text,
  Region text,
  Product ID text,
  Sales real,
  Quantity integer,
  Discount real,
  Profit real
);
CREATE TABLE east_superstore (
  Row ID integer PRIMARY KEY,
  Order ID text,
  Order Date date,
  Ship Date date,
  Ship Mode text,
  Customer ID text,
  Region text,
  Product ID text,
  Sales real,
  Quantity integer,
  Discount real,
  Profit real
);
CREATE TABLE south_superstore (
  Row ID integer PRIMARY KEY,
  Order ID text,
  Order Date date,
  Ship Date date,
  Ship Mode text,
  Customer ID text,
  Region text,
  Product ID text,
  Sales real,
  Quantity integer,
  Discount real,
  Profit real
);
CREATE TABLE west_superstore (
  Row ID integer PRIMARY KEY,
  Order ID text,
  Order Date date,
  Ship Date date,
  Ship Mode text,
  Customer ID text,
  Region text,
  Product ID text,
  Sales real,
  Quantity integer,
  Discount real,
  Profit real
);
-- foreign keys: central_superstore.Product ID -> product.Product ID; central_superstore.Region -> product.Region; central_superstore.Customer ID -> people.Customer ID; central_superstore.Region -> people.Region; east_superstore.Product ID -> product.Product ID; east_superstore.Region -> product.Region; east_superstore.Customer ID -> people.Customer ID; east_superstore.Region -> people.Region; south_superstore.Product ID -> product.Product ID; south_superstore.Region -> product.Region; south_superstore.Customer ID -> people.Customer ID; south_superstore.Region -> people.Region; west_superstore.Product ID -> product.Product ID; west_superstore.Region -> product.Region; west_superstore.Customer ID -> people.Customer ID; west_superstore.Region -> people.Region

Hint: highest profit refers to MAX(profit); Region = 'East'

Question: Who is the customer from the East region that purchased the order with the highest profit?

assistant: SELECT T2.`Customer Name` FROM east_superstore AS T1 INNER JOIN people AS T2 ON T1.`Customer ID` = T2.`Customer ID` WHERE T1.Region = 'East' ORDER BY T1.Profit DESC LIMIT 1
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
CREATE TABLE characters (
  movie_title text PRIMARY KEY,
  release_date text,
  hero text,
  villian text,
  song text
);
CREATE TABLE director (
  name text PRIMARY KEY,
  director text
);
CREATE TABLE movies_total_gross (
  movie_title text PRIMARY KEY,
  release_date text PRIMARY KEY,
  genre text,
  MPAA_rating text,
  total_gross text,
  inflation_adjusted_gross text
);
CREATE TABLE revenue (
  Year integer PRIMARY KEY,
  Studio Entertainment[NI 1] real,
  Disney Consumer Products[NI 2] real,
  Disney Interactive[NI 3][Rev 1] integer,
  Walt Disney Parks and Resorts real,
  Disney Media Networks text,
  Total integer
);
CREATE TABLE voice-actors (
  character text PRIMARY KEY,
  voice-actor text,
  movie text
);
-- foreign keys: characters.hero -> voice-actors.character; director.name -> characters.movie_title; movies_total_gross.movie_title -> characters.movie_title; voice-actors.movie -> characters.movie_title

Hint: SUBTRACT(SUM(Year = 1998), SUM(Year = 1997))

Question: How much more total box office gross did the Walt Disney Company have in revenue in 1998 than in 1997?

assistant: SELECT SUM(CASE WHEN `Year` = 1998 THEN Total ELSE 0 END) - SUM(CASE WHEN `Year` = 1997 THEN Total ELSE 0 END) FROM revenue
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
PRAGMA foreign_keys = ON;


CREATE TABLE "stadium" (
"id" int,
"name" text,
"Home_Games" int,
"Average_Attendance" real,
"Total_Attendance" real,
"Capacity_Percentage" real,
primary key ("id")
);

CREATE TABLE "game" (
"stadium_id" int,
"id" int,
"Season" int,
"Date" text,
"Home_team" text,
"Away_team" text,
"Score" text,
"Competition" text,
primary key ("id"),
foreign key ("stadium_id") references `stadium`("id")
);

CREATE TABLE "injury_accident" (
"game_id" int,
"id" int,
"Player" text,
"Injury" text,
"Number_of_matches" text,
"Source" text,
primary key ("id"),
foreign key ("game_id") references `game`("id")
);

Question: List the season, home team, away team of all the games.

assistant: SELECT season , home_team , away_team FROM game
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
CREATE TABLE genre (
  id integer PRIMARY KEY,
  genre_name text
);
CREATE TABLE game (
  id integer PRIMARY KEY,
  genre_id integer,
  game_name text
);
CREATE TABLE platform (
  id integer PRIMARY KEY,
  platform_name text
);
CREATE TABLE publisher (
  id integer PRIMARY KEY,
  publisher_name text
);
CREATE TABLE game_publisher (
  id integer PRIMARY KEY,
  game_id integer,
  publisher_id integer
);
CREATE TABLE game_platform (
  id integer PRIMARY KEY,
  game_publisher_id integer,
  platform_id integer,
  release_year integer
);
CREATE TABLE region (
  id integer PRIMARY KEY,
  region_name text
);
CREATE TABLE region_sales (
  region_id integer,
  game_platform_id integer,
  num_sales real
);
-- foreign keys: game.genre_id -> genre.id; game_publisher.publisher_id -> publisher.id; game_publisher.game_id -> game.id; game_platform.platform_id -> platform.id; game_platform.game_publisher_id -> game_publisher.id; region_sales.region_id -> region.id; region_sales.game_platform_id -> game_platform.id

Hint: names of the games refers to game_name; American Softworks refers to publisher_name = 'American Softworks';

Question: What are the names of the games published by American Softworks?

assistant: SELECT T3.game_name FROM publisher AS T1 INNER JOIN game_publisher AS T2 ON T1.id = T2.publisher_id INNER JOIN game AS T3 ON T2.game_id = T3.id WHERE T1.publisher_name = 'American Softworks'
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
CREATE TABLE height_info (
  height_id integer PRIMARY KEY,
  height_in_cm integer,
  height_in_inch text
);
CREATE TABLE weight_info (
  weight_id integer PRIMARY KEY,
  weight_in_kg integer,
  weight_in_lbs integer
);
CREATE TABLE PlayerInfo (
  ELITEID integer PRIMARY KEY,
  PlayerName text,
  birthdate text,
  birthyear date,
  birthmonth integer,
  birthday integer,
  birthplace text,
  nation text,
  height integer,
  weight integer,
  position_info text,
  shoots text,
  draftyear integer,
  draftround integer,
  overall integer,
  overallby text,
  CSS_rank integer,
  sum_7yr_GP integer,
  sum_7yr_TOI integer,
  GP_greater_than_0 text
);
CREATE TABLE SeasonStatus (
  ELITEID integer,
  SEASON text,
  TEAM text,
  LEAGUE text,
  GAMETYPE text,
  GP integer,
  G integer,
  A integer,
  P integer,
  PIM integer,
  PLUSMINUS integer
);
-- foreign keys: PlayerInfo.weight -> weight_info.weight_id; PlayerInfo.height -> height_info.height_id; SeasonStatus.ELITEID -> PlayerInfo.ELITEID

Hint: names of players refers to PlayerName; height over 5'9 refers to height_in_inch > '5''9"';

Question: List the name of players who have a height over 5'9.

assistant: SELECT T1.PlayerName FROM PlayerInfo AS T1 INNER JOIN height_info AS T2 ON T1.height = T2.height_id WHERE T2.height_in_inch > '5''9"'
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
CREATE TABLE offices (
  officeCode text PRIMARY KEY,
  city text,
  phone text,
  addressLine1 text,
  addressLine2 text,
  state text,
  country text,
  postalCode text,
  territory text
);
CREATE TABLE employees (
  employeeNumber integer PRIMARY KEY,
  lastName text,
  firstName text,
  extension text,
  email text,
  officeCode text,
  reportsTo integer,
  jobTitle text
);
CREATE TABLE customers (
  customerNumber integer PRIMARY KEY,
  customerName text,
  contactLastName text,
  contactFirstName text,
  phone text,
  addressLine1 text,
  addressLine2 text,
  city text,
  state text,
  postalCode text,
  country text,
  salesRepEmployeeNumber integer,
  creditLimit real
);
CREATE TABLE orders (
  orderNumber integer PRIMARY KEY,
  orderDate date,
  requiredDate date,
  shippedDate date,
  status text,
  comments text,
  customerNumber integer
);
CREATE TABLE payments (
  customerNumber integer PRIMARY KEY,
  checkNumber text PRIMARY KEY,
  paymentDate date,
  amount real
);
CREATE TABLE productlines (
  productLine text PRIMARY KEY,
  textDescription text,
  htmlDescription text,
  image blob
);
CREATE TABLE products (
  productCode text PRIMARY KEY,
  productName text,
  productLine text,
  productScale text,
  productVendor text,
  productDescription text,
  quantityInStock integer,
  buyPrice real,
  MSRP real
);
CREATE TABLE orderdetails (
  orderNumber integer PRIMARY KEY,
  productCode text PRIMARY KEY,
  quantityOrdered integer,
  priceEach real,
  orderLineNumber integer
);
-- foreign keys: employees.reportsTo -> employees.employeeNumber; employees.officeCode -> offices.officeCode; customers.salesRepEmployeeNumber -> employees.employeeNumber; orders.customerNumber -> customers.customerNumber; payments.customerNumber -> customers.customerNumber; products.productLine -> productlines.productLine

Hint: SUM(MULTIPLY(quantityOrdered, priceEach)) where orderDate = '2003-03-03'; customerName = 'Cruz & Sons Co.'

Question: What is the total price of the order made by Cruz & Sons Co. on 2003/3/3?

assistant: SELECT SUM(t1.priceEach * t1.quantityOrdered) FROM orderdetails AS t1 INNER JOIN orders AS t2 ON t1.orderNumber = t2.orderNumber INNER JOIN customers AS t3 ON t2.customerNumber = t3.customerNumber WHERE t3.customerName = 'Cruz & Sons Co.' AND t2.orderDate = '2003-03-03'
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
-- phpMyAdmin SQL Dump
-- version 4.0.10.7
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Mar 20, 2015 at 01:43 AM
-- Server version: 5.5.34-cll-lve
-- PHP Version: 5.4.23



/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
CREATE TABLE IF NOT EXISTS `regions` (
  `REGION_ID` decimal(5,0) NOT NULL,
  `REGION_NAME` varchar(25) DEFAULT NULL,
  PRIMARY KEY (`REGION_ID`)
);

--
-- Dumping data for table `regions`
--

Question: What are the unique ids of those departments where any manager is managing 4 or more employees.

assistant: SELECT DISTINCT department_id FROM employees GROUP BY department_id , manager_id HAVING COUNT(employee_id) >= 4