# Lateral Derived Table

Published articles for Lateral Derived Table.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## LATERAL is Your Friend to Create Local Column Variables in SQL

DevFeed: [LATERAL is Your Friend to Create Local Column Variables in SQL](<https://devfeed.tech/articles/lateral-is-your-friend-to-create-local-column-variables-in-sql-28955.md>)

Original publisher: [Read original article](<https://blog.jooq.org/lateral-is-your-friend-to-create-local-column-variables-in-sql/>)

Author: lukaseder

Published: 2022-11-04T08:56:17Z

Content type: tutorial

Language: en

Sources: [jOOQ](<https://devfeed.tech/sources/jooq.md>)

Topics: [SQL](<https://devfeed.tech/topics/sql.md>), [Databases](<https://devfeed.tech/topics/databases.md>)

Tags: [apply](<https://devfeed.tech/tags/apply.md>), [cross-apply](<https://devfeed.tech/tags/cross-apply.md>), [cross-join-lateral](<https://devfeed.tech/tags/cross-join-lateral.md>), [derived-table](<https://devfeed.tech/tags/derived-table.md>), [examples](<https://devfeed.tech/tags/examples.md>), [lateral](<https://devfeed.tech/tags/lateral.md>), [lateral-derived-table](<https://devfeed.tech/tags/lateral-derived-table.md>), [local-variables](<https://devfeed.tech/tags/local-variables.md>), [oracle](<https://devfeed.tech/tags/oracle.md>), [outer-apply](<https://devfeed.tech/tags/outer-apply.md>), [postgresql](<https://devfeed.tech/tags/postgresql.md>), [sql](<https://devfeed.tech/tags/sql.md>), [sql-server](<https://devfeed.tech/tags/sql-server.md>), [variables](<https://devfeed.tech/tags/variables.md>)

### AI overview

This article explains how SQL's LATERAL clause can be used to define local column variables next to the tables that provide their values. It compares this approach with derived tables and notes database-specific syntax, including SQL Server's CROSS APPLY.

### Source excerpt

The standard SQL WITH clause has been tremendously helpful in structuring SQL queries. Instead of nesting everything in unreadable derived tables like this: People have started moving the logic up front, just like in any other programming language, where we declare things first, lexically, then use them: Both queries will produce the 5 actors with ... Continue reading LATERAL is Your Friend to Create Local Column Variables in SQL ->