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 |
|
dim
Yak Posting Veteran
57 Posts |
Posted - 2010-08-10 : 14:50:03
|
| Hi,I am fairy new to SQL server programming and would like guidance regarding the following scenario.I have a table with the Sales Representative and No of calls each sales represenatative got during the day.I need to write the query to select top 5 sales representative based on the no of calls received.My below query gives the sales represenative along the total no of calls received during the day .....select Representative_Name,sum(dbo.Sales.Number_of_Total_Calls) as Number_Of_Total_Calls fromdbo.Sales group byRepresentative_NameI need top 5 based on the Number_Of_Total_Calls ....Thank you,dim Dp |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-08-10 : 14:56:15
|
| [code]select top 5 Representative_Namefrom(select Representative_Name,sum(dbo.Sales.Number_of_Total_Calls) as Number_Of_Total_Calls fromdbo.Sales group byRepresentative_Name)torder by Number_Of_Total_Calls desc[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|