Subqueries

Sometimes {dbplyr} uses subqueries to translate {dplyr} code

  • subquery = query used in FROM in place of a table
flights |> 
  mutate(
    year1 = year + 1,
    year2 = year1 + 1
  ) |> 
  show_query()
## <SQL>
## SELECT q01.*, year1 + 1.0 AS year2
## FROM (
##   SELECT flights.*, "year" + 1.0 AS year1
##   FROM flights
## ) q01