List the top 10 customers by total gross sales. List customers' first and last name and total gross sales.
CREATE TABLE invoices (total INTEGER, customer_id VARCHAR); CREATE TABLE customers (first_name VARCHAR, last_name VARCHAR, id VARCHAR)
SELECT TOP 10 T1.first_name, T1.last_name, SUM(T2.total) FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id = T1.id GROUP BY T1.id ORDER BY SUM(T2.total) DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE invoices (total INTEGER, customer_id VARCHAR); CREATE TABLE customers (first_name VARCHAR, last_name VARCHAR, id VARCHAR) Question: List the top 10 customers by total gross sales. List customers' first and last name and total gross sales. [/INST] SELECT TOP 10 T1.first_name, T1.last_name, SUM(T2.total) FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id = T1.id GROUP BY T1.id ORDER BY SUM(T2.total) DESC </s>