June 2024
Intermediate to advanced
456 pages
11h 34m
English
Subquery expressions[138] or “subqueries” combine multiple queries into a single statement. An outer query uses an inner query as a way to filter rows. Filtering is usually conducted with a WHERE clause or IN clause. Generating subqueries has been possible with Active Record dating back to version 3.
To get familiar with subqueries in Active Record, adapt an example from the “PostgreSQL Tutorial on Subqueries”[139] to Rideshare. Create an analytical query to show how multiple queries can be combined in a single statement. First, write the query using SQL and then convert it to Active Record. The query has these goals:
Read now
Unlock full access