On Tue, Dec 20, 2011 at 5:21 AM, John Gillespie <rjkgilles...@gmail.com> wrote:
> This would make a good entry for an Obfuscated SQL contest.
> Well done

Thanks, I guess :)  It was a fun little SQL ditty to write, and only
took a few minutes.  (Now I do I a search and see that factorial in
SQL is a fairly common toy problem, and here you can see a recursive
query version of factorial:
http://www.sqlservercentral.com/Forums/Topic164151-213-2.aspx (on page
2, today, search for "with fact").

It'd be nice to have recursive queries (with tail-call optimization).
Then a lot of things get easier.  Of course, recursive algorithms (and
thus recursive queries) do tend to look obfuscated to some, but a
combination of C/Python/... and SQL can also look obfuscated, so it's
really a question of what you're trading off for what, and the best
thing to do is to go for maintainability (i.e., readability), because
someone will have to support whatever code you write.  Taking
advantage of SQL expressibility requires writing lengthy block
comments for the benefit of the next person to read that code.

Nico
--
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to