

Using common table expressions to solve the “eight queens” problem in SQL - ThePhysicist
http://www.andreas-dewes.de/en/2015/queens-of-the-data-age-abusing-common-table-expressions-to-solve-the-eight-queens-problem-in-sql/

======
zrail
Recursive CTEs are super cool! I don't use them very often for the problems
I'm trying to solve, but I regularly use non-recursive CTEs to organize
queries instead of using deeply nested subqueries.

~~~
peri
I hope you warn your dbas before you do this :)

~~~
zrail
Are you referring to the fact that CTEs are an optimization boundary in
PostgreSQL and (presumably) most other systems? In any case, most of the time
I'm the DBA so it doesn't really matter ;)

~~~
peri
Sorry to poke this thread so far later, but I was actually thinking more of
other users of your VMs if you're doing this in the cloud :)

------
monokrome
It's worth noting here that the comment suggesting "\--note the 'RECURSIVE'
keyword, which states that we want to define a CTE" isn't exactly correct.
This is a recursive CTE, but the RECURSIVE isn't required for it to still be a
CTE...

~~~
ThePhysicist
Good point, I'll change it in the text!

