Which is the toughest query you have written until now?

SQL Question

Nothing is tough if one decides to practice it. so continuous practice will make any tough query an easy one.

1 Like

I wrote a reporting query once that was 700 lines long and visited 27 different tables in lookups or joins. It didn’t do any fancy stuff - just straight whereclause predicates and joining - but it was pretty gnarly and took 3 days to compose, debug, and tune.

It had to run in under 15 minutes on a DB world where the tables it visited had up to 5 billion records each, so it had to be well-tuned - even though it couldn’t help but be icky.

I was very, very careful with the formatting - and the query had about 1000 lines of comments around it so I could remember just what the heck I was doing when - as always happens with reports - the execs wanted stuff to be slightly different six months later

1 Like