instruction_response_pair_list
[{'instruction': 'Show me how to select all columns from a table',
'responses': 'SELECT * FROM table_name;'},
{'instruction': 'Can you give me the SQL command to select specific columns from a table',
'responses': 'SELECT column1, column2, column3 FROM table_name;'},
{'instruction': 'How do I select data from a table where a column has a certain value',
'responses': "SELECT * FROM table_name WHERE column_name = 'certain_value';"},
{'instruction': 'Can you show me how to filter rows in a table',
'responses': 'SELECT * FROM table_name WHERE condition;'},
{'instruction': 'I need to select datawhere multiple conditionsare met',
'responses': 'SELECT * FROM table_name WHERE condition1 AND condition2 AND condition3;'},
{'instruction': 'How do I select only distinct values from a column',
'responses': 'SELECT DISTINCT column_name FROM table_name;'},
{'instruction': 'Can you help me select data with a limit on the number of rows',
'responses': 'SELECT * FROM table_name LIMIT 10;'},
{'instruction': 'How do I select data and sort it by a column',
'responses': 'SELECT * FROM table_name ORDER BY column_name;'},
{'instruction': 'Show me how to selectdatawith an order by clause',
'responses': 'SELECT * FROM table_name ORDER BY column_name;'},
{'instruction': 'Can you give me the command to select data and group it by a column',
'responses': 'SELECT column1, COUNT(*) FROM table_name GROUP BY column1;'},
{'instruction': 'How do I use the where clause to select data',
'responses': 'SELECT * FROM table_name WHERE condition;'},
{'instruction': 'Can you show me how to select data using a subquery',
'responses': '```sql\nSELECT column_name\nFROM table_name\nWHERE column_name IN (SELECT column_name FROM table_name WHERE condition);\n```'},
{'instruction': 'I need to select data from multiple tables at once',
'responses': 'SELECT * FROM table1 JOIN table2 ON table1.id = table2.id JOIN table3 ON table2.id = table3.id;'},
{'instruction': 'How do I select data with a join between two tables',
'responses': 'SELECT * FROM table1 JOIN table2 ON table1.id = table2.id;'},
{'instruction': 'Can you show me how to select data with an inner join',
'responses': 'SELECT * FROM table1 INNER JOIN table2 ON table1.id = table2.id;'},
{'instruction': 'How doIselectdatawithaleftjoin',
'responses': 'SELECT * FROM table1 LEFT JOIN table2 ON table1.id = table2.id'},
{'instruction': 'Can you help me select data with a right join',
'responses': 'SELECT * FROM table1 RIGHT JOIN table2 ON table1.id = table2.id;'},
{'instruction': 'Show me how to select data with a full outer join',
'responses': 'SELECT * FROM table1 FULL OUTER JOIN table2 ON table1.id = table2.id;'},
{'instruction': 'How do I select data and apply a function to a column',
'responses': 'SELECT column_name, FUNCTION_NAME(column_name) FROM table_name;'},
{'instruction': 'Can you show me howtouselectdatawith a union clause',
'responses': '```sql\nSELECT column1, column2 FROM table1\nUNION\nSELECT column1, column2 FROM table2;\n```'},
{'instruction': 'Add a new record to the customers table',
'responses': 'INSERT INTO customers (column1, column2, column3) VALUES (value1, value2, value3);'},
{'instruction': 'Insert a row into the products table',
'responses': 'INSERT INTO products (column1, column2, column3) VALUES (value1, value2, value3);'},
{'instruction': 'Put new dataintotheorders table',
'responses': 'INSERT INTO orders (column1, column2, column3) VALUES (value1, value2, value3);'},
{'instruction': 'Add a new entry to the employees table',
'responses': 'INSERT INTO employees (column1, column2, column3) VALUES (value1, value2, value3);'},
{'instruction': 'Insert a record into the inventory table',
'responses': 'INSERT INTO inventory (column1, column2, column3) VALUES (value1, value2, value3);'},
{'instruction': 'Add a new item to the sales table',
'responses': "INSERT INTO sales (item_name, quantity, price) VALUES ('New Item', 1, 100.00);"},
{'instruction': 'Put a new row in the suppliers table',
'responses': 'INSERT INTO suppliers (column1, column2, column3) VALUES (value1, value2, value3);'},
{'instruction': 'Insert a new record into the categories table',
'responses': "INSERT INTO categories (category_name, description) VALUES ('New Category', 'Description for the new category');"},
{'instruction': 'Add a new entry to the payments table',
'responses': "INSERT INTO payments (customer_id, payment_date, amount) VALUES (123, '2023-10-01', 500.00);"},
{'instruction': 'Put a new record in the shipments table',
'responses': 'INSERT INTO shipments (column1, column2, column3) VALUES (value1, value2, value3);'},
{'instruction': 'Add a new row to the returns table',
'responses': 'INSERT INTO returns (column1, column2, column3) VALUES (value1, value2, value3);'},
{'instruction': 'Insert a record into the discounts table',
'responses': 'INSERT INTO discounts (column1, column2, column3) VALUES (value1, value2, value3);'},
{'instruction': 'Add a newentrytotheusers table',
'responses': 'INSERT INTO users (column1, column2, column3) VALUES (value1, value2, value3);'},
{'instruction': 'Put a newrecordin the addresses table',
'responses': 'INSERT INTO addresses (column1, column2, column3) VALUES (value1, value2, value3);'},
{'instruction': 'Insert a new row into the transactions table',
'responses': 'INSERT INTO transactions (column1, column2, column3) VALUES (value1, value2, value3);'},
{'instruction': 'Add a new record to the reviews table',
'responses': 'INSERT INTO reviews (column1, column2, column3) VALUES (value1, value2, value3);'},
{'instruction': 'Put a new entry in the feedbacks table',
'responses': 'INSERT INTO feedbacks (column1, column2, column3) VALUES (value1, value2, value3);'},
{'instruction': 'Insert a record into the sessions table',
'responses': "INSERT INTO sessions (session_id, user_id, start_time, end_time) VALUES ('12345', 'user1', '2023-10-01 08:00:00', '2023-10-01"},
{'instruction': 'Add a new row to the logs table',
'responses': 'INSERT INTO logs (column1, column2, column3) VALUES (value1, value2, value3);'},
{'instruction': 'Put a new record in the settings table',
'responses': 'INSERT INTO settings (column1, column2, column3) VALUES (value1, value2, value3);'},
{'instruction': 'Add a new entry to the configurations table',
'responses': "INSERT INTO configurations (setting_name, value) VALUES ('new_setting', 'new_value');"},
{'instruction': 'Update the email for a specific user in the users table',
'responses': "UPDATE users SET email = 'new_email@example.com' WHERE user_id = 123;"},
{'instruction': 'Change the status of an order to completed',
'responses': "UPDATE orders SET status = 'completed' WHERE order_id = [specific_order_id];"},
{'instruction': 'Set the quantity of a product to zero if it is out of stock',
'responses': 'UPDATE products SET quantity = 0 WHERE in_stock = false;'},
{'instruction': 'Update the last login date for a user',
'responses': 'UPDATE users SET last_login_date = CURRENT_DATE WHERE user_id = 1;'},
{'instruction': 'Change the price of a product by a certain percentage',
'responses': 'UPDATE products SET price = price * (1 + :percentage) WHERE product_id = :product_id;'},
{'instruction': 'Update the address for a customer in the customers table',
'responses': "UPDATE customers SET address = 'New Address' WHERE customer_id = 123;"},
{'instruction': 'Mark a task as incomplete if it is overdue',
'responses': "UPDATE tasks SET status = 'incomplete' WHERE due_date < CURRENT_DATE AND status = 'complete';"},
{'instruction': 'Change the manager of a department',
'responses': 'UPDATE departments SET manager_id = new_manager_id WHERE department_id = specific_department_id;'},
{'instruction': 'Update the rating of a movie in the movies table',
'responses': "UPDATE movies SET rating = 'new_rating' WHERE movie_id = 'specific_movie_id';"},
{'instruction': 'Change the category of a product',
'responses': "UPDATE products SET category = 'new_category' WHERE product_id = 'product_id';"},
{'instruction': 'Update the phone number for a supplier',
'responses': "UPDATE suppliers SET phone_number = 'new_phone_number' WHERE supplier_id = 'supplier_id';"},
{'instruction': 'Set the active status of a user to false',
'responses': 'UPDATE users SET active = false WHERE id = [user_id];'},
{'instruction': 'Change the discount rate for a customer',
'responses': 'UPDATE customers SET discount_rate = 0.15 WHERE customer_id = 123;'},
{'instruction': 'Update the publication year of a book',
'responses': 'UPDATE books SET publication_year = 2023 WHERE book_id = 1;'},
{'instruction': 'Change the department of an employee',
'responses': "UPDATE employees SET department = 'new_department' WHERE employee_id = 'employee_id';"},
{'instruction': 'Update the balance of a bank account',
'responses': "UPDATE bank_accounts SET balance = balance + 500 WHERE account_number = '123456789';"},
{'instruction': 'Change the availability of a room in the hotel table',
'responses': "UPDATE hotel SET availability = 'unavailable' WHERE room_number = '101';"},
{'instruction': 'Update the expiry date for a subscription',
'responses': "UPDATE subscriptions SET expiry_date = '2023-12-31' WHERE subscription_id = 1;"},
{'instruction': 'Change the status of a ticket to used',
'responses': "UPDATE tickets SET status = 'used' WHERE ticket_id = 12345;"},
{'instruction': 'Update the version number of an app in the apps table',
'responses': "UPDATE apps SET version_number = 'new_version_number' WHERE app_name = 'app_name';"},
{'instruction': 'Delete all records from the users table where the email is null',
'responses': 'DELETE FROM users WHERE email IS NULL;'},
{'instruction': 'Can you remove the row where the user ID is 123',
'responses': 'DELETE FROM users WHERE user_id = 123;'},
{'instruction': 'How do I delete entries that have a specific date',
'responses': "DELETE FROM table_name WHERE date_column = 'specific_date';"},
{'instruction': 'I need to clear out all the data in the orders table',
'responses': 'DELETE FROM orders;'},
{'instruction': 'Can you please deleteTheRecordWhereTheCustomerNameIsJohnDoe',
'responses': "DELETE FROM customers WHERE customer_name = 'John Doe';"},
{'instruction': 'Remove all the items from the inventory where the quantity is zero',
'responses': 'DELETE FROM inventory WHERE quantity = 0;'},
{'instruction': 'Could you delete the record with the product ID 456',
'responses': 'DELETE FROM products WHERE product_id = 456;'},
{'instruction': 'How can I remove all the duplicate entries in this table',
'responses': 'DELETE FROM table_name WHERE id NOT IN (SELECT MIN(id) FROM table_name GROUP BY column1, column2, column3);'},
{'instruction': 'I want to delete all the records older than one year',
'responses': 'DELETE FROM table_name WHERE date_column < DATE_SUB(CURDATE(), INTERVAL 1 YEAR);'},
{'instruction': 'Can you help me delete a specific record from the database',
'responses': 'DELETE FROM table_name WHERE condition;'},
{'instruction': 'How do I delete a row in a table',
'responses': 'DELETE FROM table_name WHERE condition;'},
{'instruction': 'I needToDeleteAllTheInactiveUsersFromTheDatabase',
'responses': 'DELETE FROM users WHERE active = 0;'},
{'instruction': 'Can you show me how to delete a record where the status is inactive',
'responses': "DELETE FROM table_name WHERE status = 'inactive';"},
{'instruction': 'Delete all the records where the price is less than 10',
'responses': 'DELETE FROM table_name WHERE price < 10;'},
{'instruction': 'I want to remove all the entries that have an empty description',
'responses': "DELETE FROM table_name WHERE description = '' OR description IS NULL;"},
{'instruction': 'Could you delete the record where the order number is 789',
'responses': 'DELETE FROM orders WHERE order_number = 789;'},
{'instruction': 'How doIRemoveAllTheRecordsThatHaveANullValueInAField',
'responses': 'DELETE FROM table_name WHERE field_name IS NULL;'},
{'instruction': 'Can you delete all the records where the category is outdated',
'responses': "DELETE FROM table_name WHERE category = 'outdated';"},
{'instruction': 'I need to delete all the records that match a certain condition',
'responses': 'DELETE FROM table_name WHERE condition;'},
{'instruction': 'Find the total number of entries in a specific table',
'responses': '```sql\nSELECT COUNT(*) FROM specific_table;\n```'},
{'instruction': 'Combine data from multiple tables into one result',
'responses': '```sql\nSELECT *\nFROM table1\nJOIN table2 ON table1.id = table2.id\nJOIN table3 ON table1.id = table3.id;\n```'},
{'instruction': 'Sum up the values in a particular column',
'responses': 'SELECT SUM(column_name) FROM table_name;'},
{'instruction': 'Get the average value of a column',
'responses': '```sql\nSELECT AVG(column_name) FROM table_name;\n```'},
{'instruction': 'Count how many times a value appears in a column',
'responses': 'SELECT value, COUNT(*) FROM table_name GROUP BY value;'},
{'instruction': 'Group data by a specific column and sum up another column',
'responses': '```sql\nSELECT column1, SUM(column2) \nFROM table_name \nGROUP BY column1;\n```'},
{'instruction': 'Show me the maximum value in a column',
'responses': 'SELECT MAX(column_name) FROM table_name;'},
{'instruction': 'Show me the minimum value in a column',
'responses': 'SELECT MIN(column_name) FROM table_name;'},
{'instruction': 'Calculate the total sales for each product category',
'responses': '```sql\nSELECT category, SUM(sales) AS total_sales\nFROM sales_table\nGROUP BY category;\n```'},
{'instruction': 'Combine the results of two queries into one list',
'responses': '```sql\nSELECT * FROM table1\nUNION ALL\nSELECT * FROM table2;\n```'},
{'instruction': 'How can I add up all the numbers in a column',
'responses': 'SELECT SUM(column_name) FROM table_name;'},
{'instruction': 'Can you tell me how many users are in each country',
'responses': '```sql\nSELECT country, COUNT(*) AS user_count\nFROM users\nGROUP BY country;\n```'},
{'instruction': 'What is the total amount spent by each customer',
'responses': 'SELECT customer_id, SUM(amount) AS total_spent FROM orders GROUP BY customer_id;'},
{'instruction': 'How do I find the average salary in the employees table',
'responses': 'SELECT AVG(salary) FROM employees;'},
{'instruction': 'Can you show me the highest and lowest values in a column',
'responses': '```sql\nSELECT MAX(column_name) AS highest_value, MIN(column_name) AS lowest_value FROM table_name;\n```'},
{'instruction': 'How can I group data by date and sum up the sales',
'responses': '```sql\nSELECT DATE(date_column), SUM(sales_column) \nFROM table_name \nGROUP BY DATE(date_column);\n```'},
{'instruction': 'I want to know the total number of orders placed each month',
'responses': "```sql\nSELECT DATE_TRUNC('month', order_date) AS month, COUNT(*) AS total_orders\nFROM orders\nGROUP BY DATE_TRUNC('month', order_date)\nORDER BY month;\n```"},
{'instruction': 'Can you count the number of unique customers in the database',
'responses': 'SELECT COUNT(DISTINCT customer_id) FROM customers;'},
{'instruction': 'How do I get the total quantity sold for each product',
'responses': '```sql\nSELECT product_id, SUM(quantity) AS total_quantity_sold\nFROM sales\nGROUP BY product_id;\n```'},
{'instruction': 'Can you show me the average rating for each movie in the database',
'responses': 'SELECT movie_id, AVG(rating) AS average_rating FROM ratings GROUP BY movie_id;'},
{'instruction': 'Combine the customer and orders tables to see all customer names and their order details',
'responses': '```sql\nSELECT customer.name, orders.order_id, orders.order_date, orders.amount\nFROM customer\nLEFT JOIN orders\nON customer.customer_id = orders.customer_id;\n```'},
{'instruction': 'I want to see which customers have placed orders how can I do that',
'responses': '```sql\nSELECT customer_id, COUNT(order_id) AS order_count\nFROM orders\nGROUP BY customer_id;\n```'},
{'instruction': 'Can you show me how to get a list of all products and the orders they are part of',
'responses': '```sql\nSELECT p.product_name, o.order_id\nFROM products p\nJOIN order_items oi ON p.product_id = oi.product_id\nJOIN orders o ON oi.order_id = o.order_id;\n```'},
{'instruction': 'How do I merge two tables that have a common column',
'responses': '```sql\nSELECT *\nFROM table1\nJOIN table2\nON table1.common_column = table2.common_column;\n```'},
{'instruction': 'I need to see all the records from table A even if there is no match in table B',
'responses': 'SELECT * FROM A LEFT JOIN B ON A.id = B.id'},
{'instruction': 'Can you help me join the users and their purchase history',
'responses': '```sql\nSELECT users.*, purchase_history.*\nFROM users\nJOIN purchase_history ON users.user_id = purchase_history.user_id;\n```'},
{'instruction': 'I want to see the names of customers who havent placed any orders',
'responses': '```sql\nSELECT name FROM customers WHERE customer_id NOT IN (SELECT customer_id FROM orders);\n```'},
{'instruction': 'How can I get a list of all employees and the departments they work in',
'responses': '```sql\nSELECT employee_name, department_name\nFROM employees\nJOIN departments ON employees.department_id = departments.department_id;\n```'},
{'instruction': 'Can you show me how to join three tables together',
'responses': '```sql\nSELECT a.*, b.*, c.*\nFROM table1 a\nJOIN table2 b ON a.common_field = b.common_field\nJOIN table3 c ON a.common_field = c.common_field;\n```'},
{'instruction': 'I need to find out which products have never been ordered',
'responses': 'SELECT product_id, product_name FROM products WHERE product_id NOT IN (SELECT product_id FROM orders)'},
{'instruction': 'How do I join tables to see all the data even if there are no matches',
'responses': '```sql\nSELECT *\nFROM table1\nFULL OUTER JOIN table2\nON table1.id = table2.id;\n```'},
{'instruction': 'Can you explain how to do a left join in simple terms',
'responses': '```sql\nSELECT a.*, b.*\nFROM table_a a\nLEFT JOIN table_b b\nON a.id = b.id;\n```'},
{'instruction': 'I want to see all the data from both tables where there is a match',
'responses': 'SELECT * FROM table1 INNER JOIN table2 ON table1.id = table2.id;'},
{'instruction': 'How can I combine data from multiple tables to get a complete view',
'responses': 'SELECT * FROM table1 JOIN table2 ON table1.id = table2.id JOIN table3 ON table1.id = table3.id;'},
{'instruction': 'Can you help me understand how to use inner join',
'responses': 'SELECT a.column1, b.column2\nFROM tableA a\nINNER JOIN tableB b\nON a.common_column = b.common_column;'},
{'instruction': 'I need to see all the records from table B even if there is no match in table A',
'responses': 'SELECT * FROM B LEFT JOIN A ON B.id = A.id'},
{'instruction': 'How do I join tables to see only the matching records',
'responses': 'SELECT * FROM table1 INNER JOIN table2 ON table1.id = table2.id;'},
{'instruction': 'Can you show me how to get a full list of customers and their orders including those who havent ordered anything',
'responses': '```sql\nSELECT c.customer_id, c.customer_name, o.order_id, o.order_date\nFROM customers c\nLEFT JOIN orders o ON c.customer_id = o.customer_id;\n```'},
{'instruction': 'I want to see all the products and their suppliers even if some products dont have a supplier',
'responses': '```sql\nSELECT p.product_name, s.supplier_name\nFROM products p\nLEFT JOIN suppliers s ON p.supplier_id = s.supplier_id;\n```'},
{'instruction': 'How can I join tables to see all the data from one table and only the matching data from another',
'responses': '```sql\nSELECT * \nFROM table1 \nLEFT JOIN table2 \nON table1.id = table2.id;\n```'},
{'instruction': 'Show me how to filter data in a table where a specific column has a certain value',
'responses': "SELECT * FROM table_name WHERE column_name = 'specific_value';"},
{'instruction': 'Can you explain how to get rows that match a condition',
'responses': 'SELECT * FROM table_name WHERE condition;'},
{'instruction': 'How do I select data where a column is not equal to a value',
'responses': "SELECT * FROM table_name WHERE column_name != 'value';"},
{'instruction': 'I need to know how to filter out rows that dont meet a criteria',
'responses': "SELECT * FROM table_name WHERE column_name = 'criteria';"},
{'instruction': 'Can you help me find records where a column is greater than a number',
'responses': 'SELECT * FROM table_name WHERE column_name > number;'},
{'instruction': 'How can I filter data for a specific date range',
'responses': "SELECT * FROM table_name WHERE date_column BETWEEN 'start_date' AND 'end_date';"},
{'instruction': 'Tell me how to exclude rows where a column is null',
'responses': 'SELECT * FROM table_name WHERE column_name IS NOT NULL;'},
{'instruction': 'How do I select entries where a column contains a specific word',
'responses': "SELECT * FROM table_name WHERE column_name LIKE '%specific_word%'"},
{'instruction': 'Can you show me how to filter data using multiple conditions',
'responses': 'SELECT * FROM table_name WHERE condition1 AND condition2;'},
{'instruction': 'I want to learn how to get data where a column is between two values',
'responses': 'SELECT * FROM table_name WHERE column_name BETWEEN value1 AND value2;'},
{'instruction': 'How can I filter data based on a list of values in a column',
'responses': 'SELECT * FROM table_name WHERE column_name IN (value1, value2, value3);'},
{'instruction': 'Can you guide me on filtering data where a column starts with a certain letter',
'responses': "SELECT * FROM table_name WHERE column_name LIKE 'A%'"},
{'instruction': 'How do I select data where a column ends with a specific character',
'responses': "SELECT * FROM table_name WHERE column_name LIKE '%specific_character'"},
{'instruction': 'I need to know how to filter data where a column is in a set of values',
'responses': 'SELECT * FROM table_name WHERE column_name IN (value1, value2, value3);'},
{'instruction': 'Can you help me filter out rows where a column is less than a value',
'responses': 'SELECT * FROM table_name WHERE column_name < value;'},
{'instruction': 'How can I filter data where a column is equal to one of several values',
'responses': 'SELECT * FROM table_name WHERE column_name IN (value1, value2, value3);'},
{'instruction': 'Show me how to filter data where a column does not contain a specific word',
'responses': "SELECT * FROM table_name WHERE column_name NOT LIKE '%specific_word%'"},
{'instruction': 'Can you explain how to filter data where a column is not in a list of values',
'responses': 'SELECT * FROM table_name WHERE column_name NOT IN (value1, value2, value3);'},
{'instruction': 'How do I select data where a column is like a pattern',
'responses': "SELECT * FROM table_name WHERE column_name LIKE 'pattern%'"},
{'instruction': 'I want to know how to filter data where a column is not like a pattern',
'responses': "SELECT * FROM table_name WHERE column_name NOT LIKE 'pattern%'"},
{'instruction': 'Show me how to sort data in ascending order',
'responses': 'SELECT * FROM table_name ORDER BY column_name ASC;'},
{'instruction': 'Can you sort this data from A to Z',
'responses': 'SELECT * FROM table_name ORDER BY column_name ASC;'},
{'instruction': 'How do I arrange the data from smallest to largest',
'responses': 'SELECT * FROM table_name ORDER BY column_name ASC;'},
{'instruction': 'Sort the records in descending order please',
'responses': 'SELECT * FROM table_name ORDER BY column_name DESC;'},
{'instruction': 'Can you put the data in order from highest to lowest',
'responses': 'SELECT * FROM table_name ORDER BY column_name DESC;'},
{'instruction': 'I need the data sorted alphabetically',
'responses': 'SELECT * FROM table_name ORDER BY column_name ASC;'},
{'instruction': 'How can I organize the data by date',
'responses': 'SELECT * FROM table_name ORDER BY date_column_name;'},
{'instruction': 'Sort the table by the second column',
'responses': '```sql\nSELECT * FROM table_name ORDER BY column2;\n```'},
{'instruction': 'Can you arrange the entries by the last name',
'responses': 'ORDER BY last_name'},
{'instruction': 'I want the results to be in reverse order',
'responses': 'ORDER BY column_name DESC;'},
{'instruction': 'How do I sort the data by multiple columns',
'responses': 'SELECT * FROM table_name ORDER BY column1, column2;'},
{'instruction': 'Can you show me the data sorted by price',
'responses': 'SELECT * FROM table_name ORDER BY price;'},
{'instruction': 'Sort the data by the first column in ascending order',
'responses': 'SELECT * FROM table_name ORDER BY column1 ASC;'},
{'instruction': 'Can you order the data by the creation date',
'responses': 'ORDER BY creation_date'},
{'instruction': 'I need the data sorted by the user ID',
'responses': 'SELECT * FROM table_name ORDER BY user_id;'},
{'instruction': 'How can I sort the data by the number of views',
'responses': '```sql\nSELECT * FROM table_name ORDER BY views;\n```'},
{'instruction': 'Can you arrange the data by the most recent entries',
'responses': 'SELECT * FROM table_name ORDER BY date_column DESC;'},
{'instruction': 'I want the data sorted by the product name',
'responses': 'SELECT * FROM products ORDER BY product_name;'},
{'instruction': 'Sort the data by the quantity in stock',
'responses': 'SELECT * FROM inventory ORDER BY quantity_in_stock;'},
{'instruction': 'Can you put the data in order by the rating',
'responses': 'SELECT * FROM table_name ORDER BY rating;'},
{'instruction': 'Find all the unique categories in a table',
'responses': 'SELECT DISTINCT category FROM table_name;'},
{'instruction': 'Combine similar data together in a table',
'responses': '```sql\nSELECT column1, column2, SUM(column3) \nFROM table_name \nGROUP BY column1, column2;\n```'},
{'instruction': 'Show me how to group data by a specific column',
'responses': '```sql\nSELECT column1, column2, COUNT(*) \nFROM table_name \nGROUP BY column1;\n```'},
{'instruction': 'Can you group the data by two columns',
'responses': 'SELECT column1, column2, COUNT(*) \nFROM table_name \nGROUP BY column1, column2;'},
{'instruction': 'How do I count items in each group',
'responses': '```sql\nSELECT group_column, COUNT(*) \nFROM table_name \nGROUP BY group_column;\n```'},
{'instruction': 'Group the data and calculate the average for eachGroup',
'responses': '```sql\nSELECT eachGroup, AVG(data) \nFROM yourTable \nGROUP BY eachGroup;\n```'},
{'instruction': 'Can you explain how to use group by with an example',
'responses': 'SELECT department, COUNT(*) AS employee_count\nFROM employees\nGROUP BY department;'},
{'instruction': 'I want to see the total sales for each product category',
'responses': '```sql\nSELECT product_category, SUM(sales) AS total_sales\nFROM sales_table\nGROUP BY product_category;\n```'},
{'instruction': 'How can I get the maximum value in each group',
'responses': '```sql\nSELECT group_column, MAX(value_column) \nFROM table_name \nGROUP BY group_column;\n```'},
{'instruction': 'Can you show me how to filter groups after grouping',
'responses': '```sql\nSELECT column1, column2, COUNT(*) \nFROM table_name \nGROUP BY column1, column2 \nHAVING COUNT(*) > 10;\n```'},
{'instruction': 'How do I group data and then sort the groups',
'responses': '```sql\nSELECT column1, column2, COUNT(*)\nFROM table_name\nGROUP BY column1, column2\nORDER BY column1, column2;\n```'},
{'instruction': 'I need to group data and then apply a function to each group',
'responses': 'SELECT column1, column2, AGGREGATE_FUNCTION(column3) FROM table_name GROUP BY column1, column2;'},
{'instruction': 'Can you help me understand the difference between group by and order by',
'responses': 'SELECT column1, column2, COUNT(*) FROM table_name GROUP BY column1, column2 ORDER BY column1, column2;'},
{'instruction': 'How do I group data and then find the minimum value in each group',
'responses': '```sql\nSELECT group_column, MIN(value_column)\nFROM table_name\nGROUP BY group_column;\n```'},
{'instruction': 'I want to group the data and then remove any duplicates',
'responses': '```sql\nSELECT DISTINCT *\nFROM table_name\nGROUP BY column1, column2;\n```'},
{'instruction': 'Can you show me how to group data and then apply multiple functions',
'responses': '```sql\nSELECT department, COUNT(*) AS num_employees, AVG(salary) AS avg_salary\nFROM employees\nGROUP BY department;\n```'},
{'instruction': 'How do I group data and then join it with another table',
'responses': '```sql\nSELECT t1.*, t2.*\nFROM (SELECT column1, column2, SUM(column3) AS sum_column3\n FROM table1\n GROUP BY column1, column2) t1\nJOIN table2 t2 ON t1.column1 = t2.column1'},
{'instruction': 'I need to group data and then pivot the results',
'responses': "```sql\nSELECT *\nFROM (\n SELECT column1, column2, column3\n FROM table_name\n GROUP BY column1, column2\n) AS subquery\nPIVOT (\n SUM(column3)\n FOR column2 IN ('value1', 'value2', '"},
{'instruction': 'Can you show me how to group data and then export the results to a CSV file',
'responses': "```sql\nCOPY (\n SELECT * \n FROM your_table \n GROUP BY your_column\n) TO '/path/to/your/file.csv' WITH CSV HEADER;\n```"},
{'instruction': 'How do I group data and then create a summary table',
'responses': '```sql\nSELECT column1, column2, COUNT(*), SUM(column3)\nFROM table_name\nGROUP BY column1, column2;\n```'},
{'instruction': 'How to use a subquery to filter data in SQL',
'responses': '```sql\nSELECT column1, column2\nFROM table1\nWHERE column1 IN (SELECT column1 FROM table2 WHERE condition);\n```'},
{'instruction': 'Can you explain how subqueries-work in simple terms',
'responses': 'SELECT * FROM (SELECT column_name FROM table_name WHERE condition) AS subquery_name;'},
{'instruction': 'Show me an example of a subquery that returns a single value',
'responses': 'SELECT (SELECT MAX(salary) FROM employees) AS highest_salary;'},
{'instruction': 'How do I use a subquery to get data from multiple tables',
'responses': 'SELECT t1.column1, t2.column2 FROM table1 t1 JOIN (SELECT column2, column3 FROM table2 WHERE condition) t2 ON t1.column1 = t2.column3 WHERE t1.condition;'},
{'instruction': 'Can you give meAnExample of a subquery that checks for the existence of certain records',
'responses': "```sql\nSELECT *\nFROM employees\nWHERE EXISTS (SELECT 1 FROM departments WHERE departments.department_id = employees.department_id AND departments.location = 'New York');\n```"},
{'instruction': 'How to write a subquery that returns multiple rows',
'responses': '```sql\nSELECT column1, column2\nFROM table1\nWHERE column1 IN (SELECT column1 FROM table2 WHERE condition);\n```'},
{'instruction': 'What is the difference between a subquery and a join',
'responses': 'No SQL command can be generated for this question as it is asking for an explanation rather than a specific SQL query.'},
{'instruction': 'Can you show me how to nest one subquery inside another',
'responses': '```sql\nSELECT outer_column\nFROM (SELECT inner_column\n FROM table_name\n WHERE condition) AS subquery_alias\nWHERE outer_condition;\n```'},
{'instruction': 'How do I use a subquery to find the maximum or minimum value in a column',
'responses': 'SELECT (SELECT MAX(column_name) FROM table_name) AS MaxValue, (SELECT MIN(column_name) FROM table_name) AS MinValue FROM table_name;'},
{'instruction': 'Can you explain how to use a subquery with comparison operators',
'responses': '```sql\nSELECT column_name\nFROM table_name\nWHERE column_name operator (SELECT column_name FROM table_name WHERE condition);\n```'},
{'instruction': 'How to use a subquery to filter results based on a condition',
'responses': 'SELECT * FROM table_name WHERE column_name IN (SELECT column_name FROM table_name WHERE condition)'},
{'instruction': 'Can you give me an example of a correlated subquery',
'responses': '```sql\nSELECT e.employee_id, e.first_name, e.last_name\nFROM employees e\nWHERE e.salary > (SELECT AVG(salary) FROM employees WHERE department_id = e.department_id);\n```'},
{'instruction': 'How do I optimize a query that uses subqueries',
'responses': "```sql\nEXPLAIN PLAN FOR\nSELECT /*+ GATHER_PLAN_STATISTICS */ *\nFROM (\n SELECT t1.*, t2.name\n FROM table1 t1\n JOIN table2 t2 ON t1.id = t2.id\n WHERE t1.status = 'active'\n"},
{'instruction': 'What are the common mistakes to avoid when writing subqueries',
'responses': "SELECT * FROM (SELECT 'Common mistakes to avoid when writing subqueries are not directly queryable as data' AS Note) AS SubqueryMistakes"},
{'instruction': 'How to use a subquery to update data in a table',
'responses': '```sql\nUPDATE table_name\nSET column_name = (SELECT column_name FROM another_table WHERE condition)\nWHERE condition;\n```'},
{'instruction': 'Can you show me how to use a subquery with aggregate functions',
'responses': 'SELECT employee_id, (SELECT AVG(salary) FROM employees) AS average_salary FROM employees WHERE salary > (SELECT AVG(salary) FROM employees);'},
{'instruction': 'How do I use a subquery to delete records from a table',
'responses': 'DELETE FROM table_name WHERE id IN (SELECT id FROM another_table WHERE condition)'},
{'instruction': 'Can you explain how to use a subquery with the IN operator',
'responses': 'SELECT column_name\nFROM table_name\nWHERE column_name IN (SELECT column_name FROM table_name WHERE condition);'},
{'instruction': 'How to use a subquery to return a list of values for a column',
'responses': 'SELECT column_name FROM (SELECT column_name FROM table_name) AS subquery_alias'},
{'instruction': 'Can you give me tips on writing efficient subqueries',
'responses': '```sql\nSELECT *\nFROM (\n SELECT column1, column2, column3\n FROM table_name\n WHERE condition\n LIMIT 100\n) AS subquery\nWHERE subquery.condition;\n```'}]