Subject | Re: [firebird-support] help on query |
---|---|
Author | Arno Brinkman |
Post date | 2003-07-29T07:24:16Z |
Hi,
Code,
SUM(CASE EXTRACT(MONTH FROM entry_date)
WHEN 1 THEN Value END) AS "January",
SUM(CASE EXTRACT(MONTH FROM entry_date)
WHEN 2 THEN Value END) AS "February",
SUM(CASE EXTRACT(MONTH FROM entry_date)
WHEN 3 THEN Value END) AS "March"
FROM
TableX
WHERE
EXTRACT(YEAR FROM entry_date) = 2003
GROUP BY
Code
Regards,
Arno Brinkman
ABVisie
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Firebird links :
http://www.firebirdsql.com
http://www.firebirdsql.info
http://www.fingerbird.de/
http://www.comunidade-firebird.org/
Nederlandse firebird nieuwsgroep :
news://80.126.130.81
> I have a few records in a table like thisSELECT
>
> Code entry_date value
> ---- ---------- -------
> 01 01.01.2003 200.00
> 01 15.01.2003 1200.00
> 02 30.01.2003 500.00
> 02 08.02.2003 100.00
> 01 15.02.2003 300.00
> 02 04.03.2003 200.00
> 01 01.03.2003 1000.00
> 02 11.03.2003 500.00
>
> and I want to generate a report like this in
> FB 1.5.
>
>
> Code January February March
> -----------------------------------------------
> 01 1400.00 300.00 1000.00
> 02 500.00 100.00 700.00
Code,
SUM(CASE EXTRACT(MONTH FROM entry_date)
WHEN 1 THEN Value END) AS "January",
SUM(CASE EXTRACT(MONTH FROM entry_date)
WHEN 2 THEN Value END) AS "February",
SUM(CASE EXTRACT(MONTH FROM entry_date)
WHEN 3 THEN Value END) AS "March"
FROM
TableX
WHERE
EXTRACT(YEAR FROM entry_date) = 2003
GROUP BY
Code
Regards,
Arno Brinkman
ABVisie
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Firebird links :
http://www.firebirdsql.com
http://www.firebirdsql.info
http://www.fingerbird.de/
http://www.comunidade-firebird.org/
Nederlandse firebird nieuwsgroep :
news://80.126.130.81