

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 8
click for more info
Not enough gems
Cost: 6 gems
1: Subqueries
incomplete
2: Subqueries
incomplete
3: Query Practice – Invoice Subquery
incomplete
4: No Tables
incomplete
5: Quiz
incomplete
This lesson's interactive features are locked, please to keep using them
When working on a back-end application, this doesn't come up often, but it's important to remember that SQL is a full programming language. We usually use it to interact with data stored in tables, but it's quite flexible and powerful.
For example, you can SELECT information that's simply calculated, with no tables necessary.
SELECT 5 + 10 AS sum;
-- 15
Finance has found that people who have lived longer than 40 years need to start thinking about retirement. Write a query that returns all columns for all users who are more than 40 years old.
Unfortunately, this table awkwardly stores age in days in the age_in_days field! Use a subquery to convert 40 years → days and filter on that. Assume every year has 365 days.