Which customer, who has made at least one payment, has spent the least money? List his or her first name, last name, and the id.
CREATE TABLE payment (customer_id VARCHAR); CREATE TABLE customer (first_name VARCHAR, last_name VARCHAR, customer_id VARCHAR)
SELECT TOP 1 T1.first_name, T1.last_name, T1.customer_id FROM customer AS T1 JOIN payment AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY SUM(amount)
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE payment (customer_id VARCHAR); CREATE TABLE customer (first_name VARCHAR, last_name VARCHAR, customer_id VARCHAR) Question: Which customer, who has made at least one payment, has spent the least money? List his or her first name, last name, and the id. [/INST] SELECT TOP 1 T1.first_name, T1.last_name, T1.customer_id FROM customer AS T1 JOIN payment AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY SUM(amount) </s>