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 |
NickyJ
Starting Member
46 Posts |
Posted - 2008-03-12 : 09:37:49
|
Hi all,I have a recordset of sayTotalSales SalesPerson Month100 Bob March250 Jim March130 Sam MarchI need to mark the highest TotalSales with say a 1, so as above would look like below : TotalSales SalesPerson Month Top100 Bob March 0250 Jim March 1130 Sam March 0Tried having clause with max but to no avail.... |
|
NickyJ
Starting Member
46 Posts |
Posted - 2008-03-12 : 09:52:55
|
Have answered this myself in the end using below SELECT x.ClientName, x.GP, p.GP, case when x.GP / p.GP < 1 Then 0 else x.GP / p.GP end as WedgeFROM ( SELECT ClientName, SUM(GP) AS GP FROM vw_TimesheetProfitCalcsByClient where AllocatedYear = '2008' and AllocatedMonth = 'March' GROUP BY ClientName ) AS xCROSS JOIN ( SELECT MAX(GP) AS GP FROM vw_TimesheetProfitCalcsByClient where AllocatedYear = '2008' and AllocatedMonth = 'March' ) AS p |
 |
|
|
|
|