Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
i have company table. companyid cname1 Company1 2 Company23 Company3tbl_resellerReserller_id Resller_name company_id1 R1 12 R2 1Reseller_SalesReseller_id Sales1 1002 500now i need to get the following reslut...is it possible to achieve in single query without using temp table or function...help pls1 Company1 R1 600
khtan
In (Som, Ni, Yak)
17689 Posts
Posted - 2006-04-07 : 06:01:17
like this ?
select c.companyid, c.cname, sum(s.Sales)from company c inner join tbl_reseller r on c.companyid = r.company_id inner join Reseller_Sales s on r.Reseller_id = s.Reseller_idgropu by c.companyid, c.cname
KH
Radhiga
Starting Member
35 Posts
Posted - 2006-04-07 : 06:10:08
Hai Thanks for the Immediate Reply. In my actual query i cannot use group by cname, b'coz i haave lot of colums from the parent table.i just sent u the sample table...im not sure is it possible
quote:Originally posted by khtan like this ?
select c.companyid, c.cname, sum(s.Sales)from company c inner join tbl_reseller r on c.companyid = r.company_id inner join Reseller_Sales s on r.Reseller_id = s.Reseller_idgropu by c.companyid, c.cname
KH
khtan
In (Som, Ni, Yak)
17689 Posts
Posted - 2006-04-07 : 06:28:08
You can post your table structure here with more sample data and the result that you want.KH