Skip to content

Instantly share code, notes, and snippets.

View sriedmue79's full-sized avatar

Steve Riedmueller sriedmue79

View GitHub Profile
@sriedmue79
sriedmue79 / CTE Example.sql
Last active September 16, 2024 14:09
IBM i - Understanding CTEs and how to combine IBM i Services using LATERAL
--
-- Description: The "Common Table Expression" (CTE) is a very powerful and useful tool which allows a temporary "table" to be
-- created in memory while a query is running. The contents of that temporary table (or "result set") can be
-- referenced elsewhere in the query.
--
-- The table functions provided by IBM as "IBM i Services" are ALSO very powerful. These functions allow us to
-- use SQL to retrieve many different details from the system. This includes details about user profiles,
-- network connections, objects, streamfiles, security, and much more.
--
-- We can leverage CTEs to combine multiple IBM i Services table functions (and views) and make them even more