473,399 Members | 3,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Pivot query in oracle- Please help!!

I have a table with following values

City STATE COLOR REGION
city1 Texas White SW
city2 Texas Gray SW
city3 Texas Gray SW
city4 Nevada Gray PAC
c5 Texas Yellow SW
c6 Florida Yellow SE
c7 Missouri Orange W
c8 Texas Orange SW

I am trying to create a report which looks like:

STATE White Gray Yellow Orange
Texas 1 2 0 1
Nevada 0 1 0 0
Florida 0 0 1 0
Missouri 0 0 0 1
I need to do this in oracle pl/sql
I tried to write this query

select state,
SUM( decode(color,'Orange',count(state),0) ) as orange,
SUM( decode(color,'Yellow',count(state),0) ) as yellow,
SUM( decode(color,'Gray',count(state),0) ) as gray
SUM( decode(color,'White',count(state),0) ) as white
from my_table
group by color

This query gives me an error "ORA-00937: not a single-group group
function"
Please help !
any ideas???

Jul 19 '05 #1
0 7695

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: longhorntx | last post by:
I have a table with following values City STATE COLOR REGION city1 Texas White SW city2 Texas Gray SW city3 Texas Gray SW city4 Nevada Gray PAC c5 Texas Yellow SW c6 Florida Yellow SE...
5
by: Brad Parks | last post by:
The following are a few rows in my table: StatedValue VehType Deductible Rate 10000 Truck 1000 9.16 11000 Truck 1000 9.02 12000 Truck 1000...
5
by: Charles Law | last post by:
I have posted this on a couple of Access and SQL Server newsgroups, but with no answer yet. There seems to be very little activity on the ones I have looked at, so I thought I would post here as...
0
by: John | last post by:
Does anyone have any suggestions on a way to automate sending an Access pivot (query) using VBA Access and Outlook?
3
by: Gert v O | last post by:
Can someone help me parsing this ms-access PIVOT sql-statement to a ms-sql-server sql-statement? Many thanks in advance TRANSFORM Count(KlantenStops.id) AS AantalVanid SELECT...
1
by: syl | last post by:
Hi I have a huge loto data and i am trying to come up with the total count of all total combination...the manual process to tiring in excel. e.g the possible combinations range from 1 up to 49. so...
0
by: barretldw | last post by:
Hi, i'm trying to convert the following query: TRANSFORM Sum(tblAssortiment.Aantal) AS SumOfAantal SELECT tblAssortiment.Assortiment FROM tblAssortiment WHERE (((tblAssortiment.Artikel)=?))...
18
by: smckibbe01 | last post by:
I have Pivot Table query in MS Access that I would like to run in SQL Server 2005. Can anyone help me to convert the syntax over to SQL Server. The following is the query in MS Access: ...
1
by: reachravi70 | last post by:
Hello Users, I am new to PERL. There is a requirement to write a PERL script to query the Oracle data based on the user input date parameter and write the output to Excel. I have the following...
1
by: NareshN | last post by:
Hi, I am getting error because of this line in stored procedure.How to enclose string value. Count(Case When Totalhours<='25:0' Then EmpNo end) as Less. 25:0 is varchar datatype so i am...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.