Recent posts

Find customers with at least one order in each table
AskAI SQL Problems

Given two tables, this SQL query finds all customers who have at least one order in each table.

155
Nov 21
Find the number of unique users in a table
AskAI SQL Problems

The goal is to find the number of unique users in a table. The table has the following columns: user_id, name. The query should return the number of unique users. In the example above, the answer would be 3.

159
Nov 21
"Return the total value of all products in a database table"
AskAI SQL Problems

Given a database table with a schema as shown above, write a SQL query that returns the total value of all products in the table.

121
Nov 21
Get names and total spending for customers who have made a purchase in the...
AskAI SQL Problems

This technical problem asks the reader to write a SQL query that returns the names and total spending for customers who have made a purchase from the store in the last 30 days. The input is provided in the form of two tables, customers and orders, and the output is expected in the form of a table with two columns, name and total_spent.

206
Nov 21
Designing a Database Schema for a Library System
AskAI SQL Problems

Design a database schema for a library system that keeps track of books, patrons, and checkouts. The system should allow patrons to check out multiple books at a time, and should keep track of when books are due back.

133
Nov 21
Find all pairs of rows with overlapping start and end times.
AskAI SQL Problems

Given a table of data with three columns: id, start, and end, this SQL query will find all pairs of rows where the start and end times overlap.

152
Nov 20
Creating a Backup and Recovery Plan for a Database
AskAI SQL Problems

You are tasked with creating a backup and recovery plan for a database. The database is currently running on a single server. The backup plan must be able to recover the database in the event of a server failure.

117
Nov 20
Find the most common value in each column of a table with two columns.
AskAI SQL Problems

Given a table with two columns, find the most common value in each column using a SQL query.

165
Nov 20