Re: aggregation in columns

From: <johnbhurley_at_sbcglobal.net>
Date: Thu, 5 Mar 2009 12:25:22 -0800 (PST)
Message-ID: <d985e0df-c06d-442d-86be-8c0b1489292d_at_o2g2000prl.googlegroups.com>



On Mar 5, 12:46 pm, orenl <oren..._at_gmail.com> wrote:
> Hi,
> I have a table named ReportData which reportes activity for a small
> but dynamic number of components
> there are 2 columns: componentId and timeMeasurement
>
> I want to defin a query which counts all the reports per each
> component per year
>
> I can do the following query
> select year(timeMeasurement), componentId, count(*)
> from ReportData
> group by year(timeMeasurement), componentId
>
> but I want to get the years as rows and the count per component as
> columns like
>         | component1 | component2 | component3
> 1999 | 150                205                0
> 2000 | 5645              6345               77
> 2001 | 6168              9168               669
>
> and so on...
>
> is it possible, remember that the number of components is dynamic
> Thanks

Lots of good examples on asktom.oracle.com ...

http://groups.google.com/group/comp.databases.oracle.server/browse_frm/thread/83a00f5cb24fdf3f# Received on Thu Mar 05 2009 - 14:25:22 CST

Original text of this message