Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CROSS TAB QUERY in SQL ...need help 1

Status
Not open for further replies.

prams

IS-IT--Management
Jul 19, 2001
1
IN
I have read about the CASE operator but i wasnt able to get the output in the way i wanted.
Here is my table structure:

Project Month Forecast

x Jan 5
x Feb 6
x Mar 5
y Jan 10
y Feb 12
y Mar 14

and i want the output something like this

Project Jan Feb Mar
x 5 6 5
y 10 12 14

and so on.

I tried using the CASE operator and got 1 for each of the forecast value because it counted the records.

could anyone help me on this.

Thanks in advance


 
Try this...

select proj,
Sum(Case When Mo = 'Jan' then forcast end) as Jan,
Sum(Case When Mo = 'Feb' then forcast end) as Feb,
Sum(Case When Mo = 'Mar' then forcast end) as Mar
From Table
group by proj
Andel
andelbarroga@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top