---
title: 'Simple selects'
---

# Simple selects

Common table expressions (CTE) are a great way to modularize complex queries.
Essentially they allow you to run multiple separate queries within a
single roundtrip to the DB.

Since CTEs are a part of the main query, query optimizers inside DB
engines are able to optimize the overall query. For example, postgres
is able to inline the CTEs inside the using queries if it decides it's
faster.

import {
  Playground,
  exampleSetup,
} from '../../../src/components/Playground'

import {
  simpleSelects
} from './0010-simple-selects'

<div style={{ marginBottom: '1em' }}>
  <Playground code={simpleSelects} setupCode={exampleSetup} />
</div>
