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.
| Author |
Topic |
|
venkatakondareddy
Starting Member
17 Posts |
Posted - 2008-12-20 : 06:01:59
|
Hihere i have problem while writing query. i.e., here i have 2 tables by the name of Asset and Issue. In Asset table i have ParentAssetId and AssetId, and in Issue table AssetId and InternalIssueRisk.Now the Question is: per AssetId aggregate all children and aggregate issuerisk.select Kaon.Asset.ParentAssetId , Avg(InternalIssueRiskId) from Kaon.Asset,Kaon.Issue where Kaon.Asset.AssetId=(select sum(Kaon.Issue.AssetId) from Kaon.Issue) group by ParentAssetIdIn feature Issue table may contain no of fields.So Any one knows send the answer to my mail... venkatakondareddy@hotmail.comPlease... Regards---------Venkat |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-12-20 : 09:16:23
|
| Select as.parentissueid, sum(is.assetid) as childasset,avg(is.internalIssuerisk) as riskFrom asset as inner join Issue isOn as.assetid= is.assetid group by as. Parentissueid |
 |
|
|
venkatakondareddy
Starting Member
17 Posts |
Posted - 2008-12-22 : 05:14:40
|
| thanks a lot sodeep for giving reply for my query.. |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-12-22 : 05:49:12
|
You will need to have a recursive CTE if there are more than one level of parent-child relationship. E 12°55'05.63"N 56°04'39.26" |
 |
|
|
venkatakondareddy
Starting Member
17 Posts |
Posted - 2008-12-23 : 02:31:06
|
| Okie peso,can you give explain how to map more than one table using CTE Hierarchy recursive?Regards----------Venkat |
 |
|
|
|
|
|