human
Schema:
Staff (staff_id, gender, first_name, last_name, email_address, phone_number)
Customers (customer_id, customer_type_code, address_line_1, address_line_2, town_city, state, email_address, phone_number)
Products (product_id, parent_product_id, product_category_code, date_product_first_available, date_product_discontinued, product_name, product_description, product_price)
Complaints (complaint_id, product_id, customer_id, complaint_outcome_code, complaint_status_code, complaint_type_code, date_complaint_raised, date_complaint_closed, staff_id)
Please answer with SQL.
assistant
Sure, I understand.
human
Which cities have customer_type_code of 'Good Credit Rating'?
assistant
SELECT DISTINCT town_city FROM customers WHERE customer_type_code = 'Good Credit Rating';
human
Which ones do not?
assistant
SELECT DISTINCT town_city FROM customers WHERE customer_type_code != 'Good Credit Rating';
human
Give the counts of the town city groups of customers in that first query.
assistant
SELECT town_city , COUNT( * ) FROM customers WHERE customer_type_code = 'Good Credit Rating' GROUP BY town_city;
human
Just return the town city with the least number.
assistant
SELECT town_city FROM customers WHERE customer_type_code = "Good Credit Rating" GROUP BY town_city ORDER BY COUNT( * ) LIMIT 1 ;