Log in

No account? Create an account
SQL geekery ... - He's just this guy, you know.

> Recent Entries
> Archive
> Friends
> Profile

Schlock Mercenary
Something Positive
Irregular Webcomic
Sluggy Freelance

June 7th, 2007

Previous Entry Share Next Entry
11:33 am - 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 ...)

Current Mood: geekygeeky

(1 touche | En garde !)


[User Picture]
Date:June 7th, 2007 11:40 am (UTC)
GAH! I have spent most of the day playing with SQL queries that dont do what I want them to do. My boss hasnt really included ANY way to link schools, postcodes and results.....grrrr

> Go to Top