How to Generate Date Ranges in Oracle SQL

I've just come across an interesting SQL question here on CodeRanch. How to generate date ranges in SQL, given any input date. The question didn't specify the SQL dialect, so let's choose Oracle SQL, which features the awesome CONNECT BY clause. The requirements specify that given any input date: Date ranges span 12 months The … Continue reading How to Generate Date Ranges in Oracle SQL

Serious SQL: A “convex hull” of “correlated tables”

Now THIS is an interesting, and challenging question on the jOOQ user group: https://groups.google.com/d/topic/jooq-user/6TBBLYt9eR8/discussion Say you have a big database with lots of tables and foreign key references. Now you would like to know all tables that are somehow inter-connected by their respective foreign key relationship "paths". You could call this a "convex hull" around … Continue reading Serious SQL: A “convex hull” of “correlated tables”

Recursive queries with Oracle’s CONNECT BY clause

Recursive or hierarchical queries are an awkward thing in SQL. Some RDBMS allow for recursiveness in Common Table Expressions (CTE's), but those queries tend to be quite unreadable. That's not the case for Oracle, which, in addition to recursive CTE's also supports a dedicated CONNECT BY clause. The general syntax for this clause looks something … Continue reading Recursive queries with Oracle’s CONNECT BY clause