Scalability

Get the average value for each id in a table
AskAI

Given a table with an id and value column, write a SQL query that returns the average value for each id.

183
Nov 11
Find the median value for each id in a table of data.
AskAI

To find the median value for each id in a table of data, you can use a query like the following: SELECT id, MAX(CASE WHEN rn = 1 THEN value END) AS median FROM (SELECT id, value, ROW_NUMBER() OVER (PARTITION BY id ORDER BY value) AS rn FROM data WHERE id IS NOT NULL) AS d GROUP BY id HAVING COUNT(*) % 2 = 1;

220
Nov 10
Find the Cheapest Product in a SQL Database
AskAI

Write a SQL query to find the cheapest product in a given table. The table schema is provided, and an example input and output are given.

222
Nov 09
Most recent signup for each email address
AskAI

Given a table of data with columns for name, email, and signup date, this SQL query will find the most recent signup for each email address.

186
Nov 05
Find the products with the highest price-to-quality ratio
AskAI

To find the products with the highest price-to-quality ratio, divide the price by the quality for each product. The product with the highest ratio is the product with the highest price- to-quality ratio.

156
Nov 01
Finding people who live in the same city as John Smith
AskAI

Given a table of data with people's names and addresses, write a SQL query to find all the people who live in the same city as 'John Smith'.

127
Nov 01
Get total sales for each day
AskAI

Write a SQL query to find the total sales for each day from a table of sales information.

198
Nov 01
Find the average price of all products.
AskAI

To find the average price of all products in a table, write a SQL query that calculates the sum of all prices divided by the count of all prices.

147
Nov 01