David Cook (davidcook) wrote,
David Cook
davidcook

  • Mood:

SQL geekery ...

So, what does the following bit of SQL do ?

with temp (num)
as (select 5 from sysibm.sysdummy1
union all
select num + 1
from temp
where num < 37)
select * from temp



... it generates a list of numbers (from 5 to 37 inclusive, in this case). Isn't that cool ?
Errr ... well, it is to me, since I seem to spend quite a bit of my time writing convoluted SQL queries on data warehouses. I originally saw something like it used to generate a list of all the dates and week numbers for a particular range, to then join against an auditing table and generate useful reports and things.
(Ok, an Excel pivot table, because that's how the users seem to prefer things. Oh well ...)
Subscribe

  • Books read in 2017 ...

    Angel of Storms - Trudi Canavan The Rhesus Chart - Charles Stross Magic for Nothing - Seanan McGuire The Annihilation Score - Charles Stross An…

  • DW and LJ

    In case anyone is looking for me on Dreamwidth, same username as on LJ (since, ummm ... 2009 !) Original post on Dreamwidth - there are…

  • Movies in 2015 ...

    Well, I'm cheating a bit, because I only saw one at the cinema, Star Wars: The Force Awakens, but I want to note down a few thoughts I had on it ...…

  • Post a new comment

    Error

    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 1 comment