That's neither more nor less comprehensible than what I often see in python's built-in DSL within list comprehensions.
At least the SQL variant has the excuse of being designed back when language design was still in its infancy. The madness in Python's list comprehensions and the ad hoc DSL in ruby has no such excuse.
The problem with SQL has never been that it's impossible to put logic in it. The problem is that it's a classic Turing Tarpit.