1sf/bird-sql-train-with-schema huggingface dataset:
Database: retail_complains
Tables: state, callcenterlogs, client, district, events, reviews
Columns (table index, column name): -1, *, 0, StateCode, 0, State, 0, Region, 1, Date received, 1, Complaint ID, 1, rand client, 1, phonefinal, 1, vru+line, 1, call_id, 1, priority, 1, type, 1, outcome, 1, server, 1, ser_start, 1, ser_exit, 1, ser_time, 2, client_id, 2, sex, 2, day, 2, month, 2, year, 2, age, 2, social, 2, first, 2, middle, 2, last, 2, phone, 2, email, 2, address_1, 2, address_2, 2, city, 2, state, 2, zipcode, 2, district_id, 3, district_id, 3, city, 3, state_abbrev, 3, division, 4, Date received, 4, Product, 4, Sub-product, 4, Issue, 4, Sub-issue, 4, Consumer complaint narrative, 4, Tags, 4, Consumer consent provided?, 4, Submitted via, 4, Date sent to company, 4, Company response to consumer, 4, Timely response?, 4, Consumer disputed?, 4, Complaint ID, 4, Client_ID, 5, Date, 5, Stars, 5, Reviews, 5, Product, 5, district_id
Question: How many clients under the age of 35 gave Eagle National Mortgage 1 star?
Evidence: age < 35; Eagle National Mortgage refers to Product = 'Eagle National Mortgage';
SQL: SELECT COUNT(T2.age) FROM reviews AS T1 INNER JOIN client AS T2 ON T1.district_id = T2.district_id WHERE T1.Product = 'Eagle National Mortgage' AND T1.Stars = 1 AND T2.age < 35
Database: retail_complains
Tables: state, callcenterlogs, client, district, events, reviews
Columns (table index, column name): -1, *, 0, StateCode, 0, State, 0, Region, 1, Date received, 1, Complaint ID, 1, rand client, 1, phonefinal, 1, vru+line, 1, call_id, 1, priority, 1, type, 1, outcome, 1, server, 1, ser_start, 1, ser_exit, 1, ser_time, 2, client_id, 2, sex, 2, day, 2, month, 2, year, 2, age, 2, social, 2, first, 2, middle, 2, last, 2, phone, 2, email, 2, address_1, 2, address_2, 2, city, 2, state, 2, zipcode, 2, district_id, 3, district_id, 3, city, 3, state_abbrev, 3, division, 4, Date received, 4, Product, 4, Sub-product, 4, Issue, 4, Sub-issue, 4, Consumer complaint narrative, 4, Tags, 4, Consumer consent provided?, 4, Submitted via, 4, Date sent to company, 4, Company response to consumer, 4, Timely response?, 4, Consumer disputed?, 4, Complaint ID, 4, Client_ID, 5, Date, 5, Stars, 5, Reviews, 5, Product, 5, district_id
Question: How many male clients born in the year 1977 were given priority 0 in their complaints?
Evidence: male refers to sex = 'Male';
SQL: SELECT COUNT(T1.sex) FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T1.sex = 'Male' AND T2.priority = 0 AND T1.year = 1997
Database: retail_complains
Tables: state, callcenterlogs, client, district, events, reviews
Columns (table index, column name): -1, *, 0, StateCode, 0, State, 0, Region, 1, Date received, 1, Complaint ID, 1, rand client, 1, phonefinal, 1, vru+line, 1, call_id, 1, priority, 1, type, 1, outcome, 1, server, 1, ser_start, 1, ser_exit, 1, ser_time, 2, client_id, 2, sex, 2, day, 2, month, 2, year, 2, age, 2, social, 2, first, 2, middle, 2, last, 2, phone, 2, email, 2, address_1, 2, address_2, 2, city, 2, state, 2, zipcode, 2, district_id, 3, district_id, 3, city, 3, state_abbrev, 3, division, 4, Date received, 4, Product, 4, Sub-product, 4, Issue, 4, Sub-issue, 4, Consumer complaint narrative, 4, Tags, 4, Consumer consent provided?, 4, Submitted via, 4, Date sent to company, 4, Company response to consumer, 4, Timely response?, 4, Consumer disputed?, 4, Complaint ID, 4, Client_ID, 5, Date, 5, Stars, 5, Reviews, 5, Product, 5, district_id
Question: List by name all customers who provided consent for the tag Older American.
Evidence: name refers to first; provided consent refers to "Consumer consent provided?" not in ('N/A', null, 'empty');
SQL: SELECT T1.first, T1.middle, T1.last FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.Tags = 'Older American' AND T2.`Consumer consent provided?` != 'N/A' AND T2.`Consumer consent provided?` IS NOT NULL AND T2.`Consumer consent provided?` != ''
Database: retail_complains
Tables: state, callcenterlogs, client, district, events, reviews
Columns (table index, column name): -1, *, 0, StateCode, 0, State, 0, Region, 1, Date received, 1, Complaint ID, 1, rand client, 1, phonefinal, 1, vru+line, 1, call_id, 1, priority, 1, type, 1, outcome, 1, server, 1, ser_start, 1, ser_exit, 1, ser_time, 2, client_id, 2, sex, 2, day, 2, month, 2, year, 2, age, 2, social, 2, first, 2, middle, 2, last, 2, phone, 2, email, 2, address_1, 2, address_2, 2, city, 2, state, 2, zipcode, 2, district_id, 3, district_id, 3, city, 3, state_abbrev, 3, division, 4, Date received, 4, Product, 4, Sub-product, 4, Issue, 4, Sub-issue, 4, Consumer complaint narrative, 4, Tags, 4, Consumer consent provided?, 4, Submitted via, 4, Date sent to company, 4, Company response to consumer, 4, Timely response?, 4, Consumer disputed?, 4, Complaint ID, 4, Client_ID, 5, Date, 5, Stars, 5, Reviews, 5, Product, 5, district_id
Question: What is the name of the state in which there have been the largest number of complaints with priority 0?
Evidence: largest number of complaints refers to MAX(COUNT("Complaint ID") WHERE priority = 0);
SQL: SELECT T2.state FROM callcenterlogs AS T1 INNER JOIN client AS T2 ON T1.`rand client` = T2.client_id INNER JOIN district AS T3 ON T2.district_id = T3.district_id INNER JOIN state AS T4 ON T3.state_abbrev = T4.StateCode WHERE T1.priority = 0 GROUP BY T2.state ORDER BY COUNT(T2.state) DESC LIMIT 1
Database: retail_complains
Tables: state, callcenterlogs, client, district, events, reviews
Columns (table index, column name): -1, *, 0, StateCode, 0, State, 0, Region, 1, Date received, 1, Complaint ID, 1, rand client, 1, phonefinal, 1, vru+line, 1, call_id, 1, priority, 1, type, 1, outcome, 1, server, 1, ser_start, 1, ser_exit, 1, ser_time, 2, client_id, 2, sex, 2, day, 2, month, 2, year, 2, age, 2, social, 2, first, 2, middle, 2, last, 2, phone, 2, email, 2, address_1, 2, address_2, 2, city, 2, state, 2, zipcode, 2, district_id, 3, district_id, 3, city, 3, state_abbrev, 3, division, 4, Date received, 4, Product, 4, Sub-product, 4, Issue, 4, Sub-issue, 4, Consumer complaint narrative, 4, Tags, 4, Consumer consent provided?, 4, Submitted via, 4, Date sent to company, 4, Company response to consumer, 4, Timely response?, 4, Consumer disputed?, 4, Complaint ID, 4, Client_ID, 5, Date, 5, Stars, 5, Reviews, 5, Product, 5, district_id
Question: How many complaints made by women and served after 3 pm received a timely response from the company?
Evidence: women refers to sex = 'Female'; served after 3 pm refers to ser_time BETWEEN '15:00:01' AND '23:59:59'; received a timely response refers to "Timely response?" = 'Yes';
SQL: SELECT COUNT(T1.`Complaint ID`) FROM callcenterlogs AS T1 INNER JOIN client AS T2 ON T1.`rand client` = T2.client_id INNER JOIN events AS T3 ON T1.`Complaint ID` = T3.`Complaint ID` WHERE T2.sex = 'Female' AND T1.ser_start BETWEEN '15:00:01' AND '23:59:59' AND T3.`Timely response?` = 'Yes'
Database: retail_complains
Tables: state, callcenterlogs, client, district, events, reviews
Columns (table index, column name): -1, *, 0, StateCode, 0, State, 0, Region, 1, Date received, 1, Complaint ID, 1, rand client, 1, phonefinal, 1, vru+line, 1, call_id, 1, priority, 1, type, 1, outcome, 1, server, 1, ser_start, 1, ser_exit, 1, ser_time, 2, client_id, 2, sex, 2, day, 2, month, 2, year, 2, age, 2, social, 2, first, 2, middle, 2, last, 2, phone, 2, email, 2, address_1, 2, address_2, 2, city, 2, state, 2, zipcode, 2, district_id, 3, district_id, 3, city, 3, state_abbrev, 3, division, 4, Date received, 4, Product, 4, Sub-product, 4, Issue, 4, Sub-issue, 4, Consumer complaint narrative, 4, Tags, 4, Consumer consent provided?, 4, Submitted via, 4, Date sent to company, 4, Company response to consumer, 4, Timely response?, 4, Consumer disputed?, 4, Complaint ID, 4, Client_ID, 5, Date, 5, Stars, 5, Reviews, 5, Product, 5, district_id
Question: How many complaints were served in 5 minutes or less by DORIT and responded to the customer with an explanation, were made by phone?
Evidence: served in 5 minutes or less refers to ser_time < '00:05:00'; DORIT refers to server = 'DORIT'; responded with an explanation refers to "Company response to consumer" = 'Closed with explanation'; made by refers to "Submitted via";
SQL: SELECT COUNT(T1.`Complaint ID`) FROM callcenterlogs AS T1 INNER JOIN events AS T2 ON T1.`Complaint ID` = T2.`Complaint ID` WHERE T1.ser_time < '00:05:00' AND T1.server = 'DORIT' AND T2.`Submitted via` = 'Phone' AND T2.`Company response to consumer` = 'Closed with explanation'
Database: retail_complains
Tables: state, callcenterlogs, client, district, events, reviews
Columns (table index, column name): -1, *, 0, StateCode, 0, State, 0, Region, 1, Date received, 1, Complaint ID, 1, rand client, 1, phonefinal, 1, vru+line, 1, call_id, 1, priority, 1, type, 1, outcome, 1, server, 1, ser_start, 1, ser_exit, 1, ser_time, 2, client_id, 2, sex, 2, day, 2, month, 2, year, 2, age, 2, social, 2, first, 2, middle, 2, last, 2, phone, 2, email, 2, address_1, 2, address_2, 2, city, 2, state, 2, zipcode, 2, district_id, 3, district_id, 3, city, 3, state_abbrev, 3, division, 4, Date received, 4, Product, 4, Sub-product, 4, Issue, 4, Sub-issue, 4, Consumer complaint narrative, 4, Tags, 4, Consumer consent provided?, 4, Submitted via, 4, Date sent to company, 4, Company response to consumer, 4, Timely response?, 4, Consumer disputed?, 4, Complaint ID, 4, Client_ID, 5, Date, 5, Stars, 5, Reviews, 5, Product, 5, district_id
Question: How many clients with the last name Alvarado are from Maryland?
Evidence: The abbreviation of Maryland is 'MD';
SQL: SELECT COUNT(T2.client_id) FROM district AS T1 INNER JOIN client AS T2 ON T1.district_id = T2.district_id INNER JOIN state AS T3 ON T1.state_abbrev = T3.StateCode WHERE T2.last = 'Alvarado' AND T2.state = 'MD'
Database: retail_complains
Tables: state, callcenterlogs, client, district, events, reviews
Columns (table index, column name): -1, *, 0, StateCode, 0, State, 0, Region, 1, Date received, 1, Complaint ID, 1, rand client, 1, phonefinal, 1, vru+line, 1, call_id, 1, priority, 1, type, 1, outcome, 1, server, 1, ser_start, 1, ser_exit, 1, ser_time, 2, client_id, 2, sex, 2, day, 2, month, 2, year, 2, age, 2, social, 2, first, 2, middle, 2, last, 2, phone, 2, email, 2, address_1, 2, address_2, 2, city, 2, state, 2, zipcode, 2, district_id, 3, district_id, 3, city, 3, state_abbrev, 3, division, 4, Date received, 4, Product, 4, Sub-product, 4, Issue, 4, Sub-issue, 4, Consumer complaint narrative, 4, Tags, 4, Consumer consent provided?, 4, Submitted via, 4, Date sent to company, 4, Company response to consumer, 4, Timely response?, 4, Consumer disputed?, 4, Complaint ID, 4, Client_ID, 5, Date, 5, Stars, 5, Reviews, 5, Product, 5, district_id
Question: How many reviews by people between 30 and 50 years include the word 'great'?
Evidence: between 30 and 50 years refers to age BETWEEN 30 AND 50; include the word great refers to Review like '%Great%';
SQL: SELECT COUNT(T1.Reviews) FROM reviews AS T1 INNER JOIN client AS T2 ON T1.district_id = T2.district_id WHERE T2.age BETWEEN 30 AND 50 AND T1.Reviews LIKE '%great%'
Database: retail_complains
Tables: state, callcenterlogs, client, district, events, reviews
Columns (table index, column name): -1, *, 0, StateCode, 0, State, 0, Region, 1, Date received, 1, Complaint ID, 1, rand client, 1, phonefinal, 1, vru+line, 1, call_id, 1, priority, 1, type, 1, outcome, 1, server, 1, ser_start, 1, ser_exit, 1, ser_time, 2, client_id, 2, sex, 2, day, 2, month, 2, year, 2, age, 2, social, 2, first, 2, middle, 2, last, 2, phone, 2, email, 2, address_1, 2, address_2, 2, city, 2, state, 2, zipcode, 2, district_id, 3, district_id, 3, city, 3, state_abbrev, 3, division, 4, Date received, 4, Product, 4, Sub-product, 4, Issue, 4, Sub-issue, 4, Consumer complaint narrative, 4, Tags, 4, Consumer consent provided?, 4, Submitted via, 4, Date sent to company, 4, Company response to consumer, 4, Timely response?, 4, Consumer disputed?, 4, Complaint ID, 4, Client_ID, 5, Date, 5, Stars, 5, Reviews, 5, Product, 5, district_id
Question: What is the full address of the customers who, having received a timely response from the company, have dispute about that response?
Evidence: full address = address_1, address_2; received a timely response refers to Timely response? = 'Yes'; have dispute refers to "Consumer disputed?" = 'Yes';
SQL: SELECT T1.address_1, T1.address_2 FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Timely response?` = 'Yes' AND T2.`Consumer disputed?` = 'Yes'
Database: retail_complains
Tables: state, callcenterlogs, client, district, events, reviews
Columns (table index, column name): -1, *, 0, StateCode, 0, State, 0, Region, 1, Date received, 1, Complaint ID, 1, rand client, 1, phonefinal, 1, vru+line, 1, call_id, 1, priority, 1, type, 1, outcome, 1, server, 1, ser_start, 1, ser_exit, 1, ser_time, 2, client_id, 2, sex, 2, day, 2, month, 2, year, 2, age, 2, social, 2, first, 2, middle, 2, last, 2, phone, 2, email, 2, address_1, 2, address_2, 2, city, 2, state, 2, zipcode, 2, district_id, 3, district_id, 3, city, 3, state_abbrev, 3, division, 4, Date received, 4, Product, 4, Sub-product, 4, Issue, 4, Sub-issue, 4, Consumer complaint narrative, 4, Tags, 4, Consumer consent provided?, 4, Submitted via, 4, Date sent to company, 4, Company response to consumer, 4, Timely response?, 4, Consumer disputed?, 4, Complaint ID, 4, Client_ID, 5, Date, 5, Stars, 5, Reviews, 5, Product, 5, district_id
Question: How many complaints from female clients born in the year 2000 were not sent through the web?
Evidence: female refers to sex = 'Female'; sent through refers to "Submitted via"; not sent through web refers to "Submitted via" ! = 'Web';

SQL: SELECT COUNT(T2.`Submitted via`) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.sex = 'Female' AND T1.year = 2000 AND T2.`Submitted via` != 'Web'
Database: retail_complains
Tables: state, callcenterlogs, client, district, events, reviews
Columns (table index, column name): -1, *, 0, StateCode, 0, State, 0, Region, 1, Date received, 1, Complaint ID, 1, rand client, 1, phonefinal, 1, vru+line, 1, call_id, 1, priority, 1, type, 1, outcome, 1, server, 1, ser_start, 1, ser_exit, 1, ser_time, 2, client_id, 2, sex, 2, day, 2, month, 2, year, 2, age, 2, social, 2, first, 2, middle, 2, last, 2, phone, 2, email, 2, address_1, 2, address_2, 2, city, 2, state, 2, zipcode, 2, district_id, 3, district_id, 3, city, 3, state_abbrev, 3, division, 4, Date received, 4, Product, 4, Sub-product, 4, Issue, 4, Sub-issue, 4, Consumer complaint narrative, 4, Tags, 4, Consumer consent provided?, 4, Submitted via, 4, Date sent to company, 4, Company response to consumer, 4, Timely response?, 4, Consumer disputed?, 4, Complaint ID, 4, Client_ID, 5, Date, 5, Stars, 5, Reviews, 5, Product, 5, district_id
Question: List all the complaints narratives made by the customer named Brenda and last name Mayer.
Evidence: complaints narratives refers to "Consumer complaint narrative";
SQL: SELECT T2.`Consumer complaint narrative` FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.first = 'Brenda' AND T1.last = 'Mayer'
Database: retail_complains
Tables: state, callcenterlogs, client, district, events, reviews
Columns (table index, column name): -1, *, 0, StateCode, 0, State, 0, Region, 1, Date received, 1, Complaint ID, 1, rand client, 1, phonefinal, 1, vru+line, 1, call_id, 1, priority, 1, type, 1, outcome, 1, server, 1, ser_start, 1, ser_exit, 1, ser_time, 2, client_id, 2, sex, 2, day, 2, month, 2, year, 2, age, 2, social, 2, first, 2, middle, 2, last, 2, phone, 2, email, 2, address_1, 2, address_2, 2, city, 2, state, 2, zipcode, 2, district_id, 3, district_id, 3, city, 3, state_abbrev, 3, division, 4, Date received, 4, Product, 4, Sub-product, 4, Issue, 4, Sub-issue, 4, Consumer complaint narrative, 4, Tags, 4, Consumer consent provided?, 4, Submitted via, 4, Date sent to company, 4, Company response to consumer, 4, Timely response?, 4, Consumer disputed?, 4, Complaint ID, 4, Client_ID, 5, Date, 5, Stars, 5, Reviews, 5, Product, 5, district_id
Question: How many complaints from customers with a gmail.com email were received by the company in February 2017?
Evidence: gmail.com email refers to email like '%gmail.com'; in February 2017 refers to "Date received" BETWEEN '2017-01-02' AND '2017-02-28';
SQL: SELECT COUNT(T1.email) FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE (T2.`Date received` LIKE '2017-02%' OR T2.`Date received` LIKE '2017-01%') AND T1.email LIKE '%@gmail.com'
Database: retail_complains
Tables: state, callcenterlogs, client, district, events, reviews
Columns (table index, column name): -1, *, 0, StateCode, 0, State, 0, Region, 1, Date received, 1, Complaint ID, 1, rand client, 1, phonefinal, 1, vru+line, 1, call_id, 1, priority, 1, type, 1, outcome, 1, server, 1, ser_start, 1, ser_exit, 1, ser_time, 2, client_id, 2, sex, 2, day, 2, month, 2, year, 2, age, 2, social, 2, first, 2, middle, 2, last, 2, phone, 2, email, 2, address_1, 2, address_2, 2, city, 2, state, 2, zipcode, 2, district_id, 3, district_id, 3, city, 3, state_abbrev, 3, division, 4, Date received, 4, Product, 4, Sub-product, 4, Issue, 4, Sub-issue, 4, Consumer complaint narrative, 4, Tags, 4, Consumer consent provided?, 4, Submitted via, 4, Date sent to company, 4, Company response to consumer, 4, Timely response?, 4, Consumer disputed?, 4, Complaint ID, 4, Client_ID, 5, Date, 5, Stars, 5, Reviews, 5, Product, 5, district_id
Question: What is the average number of stars given by Oregon clients in their reviews?
Evidence: average = DIVIDE(SUM(State = 'Oregon'), COUNT(district_id)); Oregon refers to state = 'Oregon';
SQL: SELECT CAST(SUM(T3.Stars) AS REAL) / COUNT(T3.Stars) AS average FROM state AS T1 INNER JOIN district AS T2 ON T1.StateCode = T2.state_abbrev INNER JOIN reviews AS T3 ON T2.district_id = T3.district_id WHERE T1.State = 'Oregon'
Database: retail_complains
Tables: state, callcenterlogs, client, district, events, reviews
Columns (table index, column name): -1, *, 0, StateCode, 0, State, 0, Region, 1, Date received, 1, Complaint ID, 1, rand client, 1, phonefinal, 1, vru+line, 1, call_id, 1, priority, 1, type, 1, outcome, 1, server, 1, ser_start, 1, ser_exit, 1, ser_time, 2, client_id, 2, sex, 2, day, 2, month, 2, year, 2, age, 2, social, 2, first, 2, middle, 2, last, 2, phone, 2, email, 2, address_1, 2, address_2, 2, city, 2, state, 2, zipcode, 2, district_id, 3, district_id, 3, city, 3, state_abbrev, 3, division, 4, Date received, 4, Product, 4, Sub-product, 4, Issue, 4, Sub-issue, 4, Consumer complaint narrative, 4, Tags, 4, Consumer consent provided?, 4, Submitted via, 4, Date sent to company, 4, Company response to consumer, 4, Timely response?, 4, Consumer disputed?, 4, Complaint ID, 4, Client_ID, 5, Date, 5, Stars, 5, Reviews, 5, Product, 5, district_id
Question: What percentage of clients who sent their complaints by postal mail are age 50 and older?
Evidence: percentage = MULTIPLY(DIVIDE(SUM("Submitted via" = 'Postal mail'), COUNT(client_id)), 1.0); sent their complaints by refers to "Submitted via"; age > 50;
SQL: SELECT CAST(SUM(CASE WHEN T1.age > 50 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T2.`Submitted via`) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Submitted via` = 'Postal mail'
Database: retail_complains
Tables: state, callcenterlogs, client, district, events, reviews
Columns (table index, column name): -1, *, 0, StateCode, 0, State, 0, Region, 1, Date received, 1, Complaint ID, 1, rand client, 1, phonefinal, 1, vru+line, 1, call_id, 1, priority, 1, type, 1, outcome, 1, server, 1, ser_start, 1, ser_exit, 1, ser_time, 2, client_id, 2, sex, 2, day, 2, month, 2, year, 2, age, 2, social, 2, first, 2, middle, 2, last, 2, phone, 2, email, 2, address_1, 2, address_2, 2, city, 2, state, 2, zipcode, 2, district_id, 3, district_id, 3, city, 3, state_abbrev, 3, division, 4, Date received, 4, Product, 4, Sub-product, 4, Issue, 4, Sub-issue, 4, Consumer complaint narrative, 4, Tags, 4, Consumer consent provided?, 4, Submitted via, 4, Date sent to company, 4, Company response to consumer, 4, Timely response?, 4, Consumer disputed?, 4, Complaint ID, 4, Client_ID, 5, Date, 5, Stars, 5, Reviews, 5, Product, 5, district_id
Question: What is the average age of Norwalk clients?
Evidence: average age = AVG(age); Norwalk refers to city = 'Norwalk';
SQL: SELECT CAST(SUM(T1.age) AS REAL) / COUNT(T1.age) AS average FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.city = 'Norwalk'
Database: retail_complains
Tables: state, callcenterlogs, client, district, events, reviews
Columns (table index, column name): -1, *, 0, StateCode, 0, State, 0, Region, 1, Date received, 1, Complaint ID, 1, rand client, 1, phonefinal, 1, vru+line, 1, call_id, 1, priority, 1, type, 1, outcome, 1, server, 1, ser_start, 1, ser_exit, 1, ser_time, 2, client_id, 2, sex, 2, day, 2, month, 2, year, 2, age, 2, social, 2, first, 2, middle, 2, last, 2, phone, 2, email, 2, address_1, 2, address_2, 2, city, 2, state, 2, zipcode, 2, district_id, 3, district_id, 3, city, 3, state_abbrev, 3, division, 4, Date received, 4, Product, 4, Sub-product, 4, Issue, 4, Sub-issue, 4, Consumer complaint narrative, 4, Tags, 4, Consumer consent provided?, 4, Submitted via, 4, Date sent to company, 4, Company response to consumer, 4, Timely response?, 4, Consumer disputed?, 4, Complaint ID, 4, Client_ID, 5, Date, 5, Stars, 5, Reviews, 5, Product, 5, district_id
Question: How many clients who live in Kansas City provided a 1-star review?
Evidence: 1-star review refers stars = 1;
SQL: SELECT COUNT(T1.Stars) FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.city = 'Kansas City' AND T1.Stars = 1
Database: retail_complains
Tables: state, callcenterlogs, client, district, events, reviews
Columns (table index, column name): -1, *, 0, StateCode, 0, State, 0, Region, 1, Date received, 1, Complaint ID, 1, rand client, 1, phonefinal, 1, vru+line, 1, call_id, 1, priority, 1, type, 1, outcome, 1, server, 1, ser_start, 1, ser_exit, 1, ser_time, 2, client_id, 2, sex, 2, day, 2, month, 2, year, 2, age, 2, social, 2, first, 2, middle, 2, last, 2, phone, 2, email, 2, address_1, 2, address_2, 2, city, 2, state, 2, zipcode, 2, district_id, 3, district_id, 3, city, 3, state_abbrev, 3, division, 4, Date received, 4, Product, 4, Sub-product, 4, Issue, 4, Sub-issue, 4, Consumer complaint narrative, 4, Tags, 4, Consumer consent provided?, 4, Submitted via, 4, Date sent to company, 4, Company response to consumer, 4, Timely response?, 4, Consumer disputed?, 4, Complaint ID, 4, Client_ID, 5, Date, 5, Stars, 5, Reviews, 5, Product, 5, district_id
Question: Which state has the highest number of clients who gave a 5-star review?
Evidence: highest number of clients refers to MAX(COUNT(client_id)); 5-star review refers to stars = 5;
SQL: SELECT T2.state_abbrev FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.Stars = 5 GROUP BY T2.state_abbrev ORDER BY COUNT(T2.state_abbrev) DESC LIMIT 1
Database: retail_complains
Tables: state, callcenterlogs, client, district, events, reviews
Columns (table index, column name): -1, *, 0, StateCode, 0, State, 0, Region, 1, Date received, 1, Complaint ID, 1, rand client, 1, phonefinal, 1, vru+line, 1, call_id, 1, priority, 1, type, 1, outcome, 1, server, 1, ser_start, 1, ser_exit, 1, ser_time, 2, client_id, 2, sex, 2, day, 2, month, 2, year, 2, age, 2, social, 2, first, 2, middle, 2, last, 2, phone, 2, email, 2, address_1, 2, address_2, 2, city, 2, state, 2, zipcode, 2, district_id, 3, district_id, 3, city, 3, state_abbrev, 3, division, 4, Date received, 4, Product, 4, Sub-product, 4, Issue, 4, Sub-issue, 4, Consumer complaint narrative, 4, Tags, 4, Consumer consent provided?, 4, Submitted via, 4, Date sent to company, 4, Company response to consumer, 4, Timely response?, 4, Consumer disputed?, 4, Complaint ID, 4, Client_ID, 5, Date, 5, Stars, 5, Reviews, 5, Product, 5, district_id
Question: Which region does Noah Thompson live in?
SQL: SELECT T2.division FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.first = 'Noah' AND T1.last = 'Thompson'