Subject Re: Query Help?
Author mcbootchek
--- In firebird-support@yahoogroups.com, Andy Goodchild
<goodieauk@y...> wrote:
> Lee Jenkins wrote:
>



Hi,

what about to use CASE command (FB 1.5). It is realy fast.

Select
yr AS 'Year'
sum(case qtr when 1 then sales ELSE NULL END) AS Q1
sum(case qtr when 2 then sales ELSE NULL END) AS Q2
sum(case qtr when 3 then sales ELSE NULL END) AS Q3
sum(case qtr when 4 then sales ELSE NULL END) AS Q4
SUM(sales) AS TOTAL
FROM ...
WHERE ...
GROUP BY yr

You can use EXTRACT() command to get info about the time (year,
month, day, hour .... weekday, yearday) from DATE, TIME, TIMESTAMP
fields


> > Very shrewd way of tackling the problem though
>
> I really can not claim the credit...Jo Celko is a bit of an SQL
genius (
> he even gets a mention in Helens book in the further reading
section so
> he must be kinda good)
>
> > ...I'm
> > look forward to timing it.
>
> Let us know how it performs in comparison to your firs method as
I've
> often wondered how the two approaches compare..