~/devreads

#apply

3 posts

4 Nov 2022

lukaseder 1 min read

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…

sqlapplycross applycross join laterallateral

15 Aug 2018

lukaseder 1 min read

Oracle is one of the few databases that implements the SQL standard ORDBMS extensions, which essentially allow for nested collections. Other databases that have these features to some extent are CUBRID, Informix, PostgreSQL. Oracle has two types of nested collections: The main difference at first is that a nested table can be of arbitrary size, … Continue reading How to…

sqlapplyexceptintersectmultiset

22 May 2017

lukaseder 1 min read

There are some situations where you would like to have at least one (empty) row in your result set in SQL. Imagine the following situation. We’re querying the Sakila database for actors and their films: yielding something like: +------------+-----------+---------------------+ | FIRST_NAME | LAST_NAME | TITLE | +------------+-----------+---------------------+ | ... | ... | ... | | … Continue reading How to…

sql1..n cardinalityapplyat least one rowleft join