Given two tables, this SQL query finds all customers who have at least one order in each table.
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.
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.
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.
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.
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.
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.
Given a table with two columns, find the most common value in each column using a SQL query.