473,385 Members | 1,320 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,385 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 7690

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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.