- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
CTEs vs nested subqueries (the WITH clause) | SQL interview
Nested subqueries are write-only code. CTEs make the same logic readable.
Common Table Expressions, the WITH clause. You name each step as its own block, then build on it, so the query reads top to bottom instead of inside out.
A CTE is a named temporary result you reference later. It doesn't change what runs, it restructures it so each transformation is a labeled step you (and the next engineer) can follow.
How it works:
- WITH step1 AS (...), step2 AS (SELECT ... FROM step1) ...
- Each CTE is a named block you can reference downstream
- Chain them so logic flows top to bottom, not nested inside out
- Great for multi-step transforms and reusing a result twice
The gotcha: a CTE referenced many times may be recomputed each time (engine-dependent), so for a heavy block used a lot, a temp table can be faster. Readability versus performance.
CTEs for readability, or subqueries the optimizer may handle better?
#sql #datainterview #dataengineering #dataanalyst #datascience #data #cte #sql #dataengineering #database
Видео CTEs vs nested subqueries (the WITH clause) | SQL interview канала The Data Round
Common Table Expressions, the WITH clause. You name each step as its own block, then build on it, so the query reads top to bottom instead of inside out.
A CTE is a named temporary result you reference later. It doesn't change what runs, it restructures it so each transformation is a labeled step you (and the next engineer) can follow.
How it works:
- WITH step1 AS (...), step2 AS (SELECT ... FROM step1) ...
- Each CTE is a named block you can reference downstream
- Chain them so logic flows top to bottom, not nested inside out
- Great for multi-step transforms and reusing a result twice
The gotcha: a CTE referenced many times may be recomputed each time (engine-dependent), so for a heavy block used a lot, a temp table can be faster. Readability versus performance.
CTEs for readability, or subqueries the optimizer may handle better?
#sql #datainterview #dataengineering #dataanalyst #datascience #data #cte #sql #dataengineering #database
Видео CTEs vs nested subqueries (the WITH clause) | SQL interview канала The Data Round
Комментарии отсутствуют
Информация о видео
9 ч. 22 мин. назад
00:00:08
Другие видео канала
