Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Creating A Crosstab Query
Abeeda_Mohammed wrote at 21-Nov-97 14:21:30
>The following is the structure of a table :
>inventory_item_id
>Organization_id
>cost_type_id
>summary_resource_id
>description
>item_cost
>I want to write a query so that I can get the sum of item_cost for each
>description, i.e the description should appear as a column. I am not sure
>what the description is going to be so I cannot write a SQL stmt. with
>sum(decode.. function to perform this crosstab query.
>Is there a way out?
I think, You are looking for the group by clause. Try this:
select sum(item_cost),description
from table
group by description;
>thanks in advance,
>Abeeda
CU,
Lothar
-- Lothar Armbrüster | lothar.armbruester_at_rheingau.netsurf.de Schulstr. 12 | lothar.armbruester_at_t-online.de D-65375 Oestrich-Winkel |Received on Mon Nov 24 1997 - 00:00:00 CST