Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Difficult Query

Author  Topic 

rookie_sql
Constraint Violating Yak Guru

443 Posts

Posted - 2008-05-29 : 07:27:27
Hey i have a query i need help with.

I have a table where i have 4 columns in it which i need to group together and then sum up a cost column also. I want to sum up the columns where i have a parent and and child and then i want to sum up the other column where i have only a child.
Example of the data is below. I think i need to do this in a sub query

ID Ind Parent Child Cost
P 1 100410 127059 21.8000
W 1 100410 127059 5.4500
A 1 100410 127059 21.8000
B 1 100410 127059 16.3500
R 1 100410 127059 16.3500
B 0 100420 0 43.3000
P 0 100420 0 43.3000
W 0 100420 0 21.6500

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-05-29 : 07:32:41
So what is the expected output for this?

quote:
then i want to sum up the other column where i have only a child.


I don't see any such record in sample data you posted.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-05-29 : 07:35:07
See http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=89365
and http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=89335



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -