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 |
|
CodingGirl
Starting Member
8 Posts |
Posted - 2007-06-28 : 09:28:02
|
I have a table that has a field TYPE with either partners, distributors or telco written in it. I have a query that’s returning the top 20 partners from this table and a total $value of the Partners in the table.What I need to return thou is the top 20 partners by $value, plus then the remaining Partners in the table (varying size table) all rolled up as Other.Any idea on how to do this? This is what i have at mo.... Thanks select Top 20 (Customer) as 'Partner', Revenue, Bookings, Commit_Amt, Upside_this_Qtr, Potential_Total from dbo.PSC_Revenue_Breakout where Customer_type Like 'Partner' union select 'Total' as Partner, sum(Revenue) as Revenue, sum(Bookings) as Bookings, sum(Commit_Amt) as Commit_Amt, sum(Upside_this_Qtr) as Upside_this_Qtr, sum(Potential_Total) as Potential_Total from dbo.PSC_Revenue_Breakout Where Customer_type Like 'Partner'order by Potential_Total |
|
|
hey001us
Posting Yak Master
185 Posts |
Posted - 2007-06-28 : 18:11:22
|
| Can I have some output result so I can try?hey |
 |
|
|
|
|
|