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 |
cool_iron007
Starting Member
1 Post |
Posted - 2010-12-09 : 12:31:24
|
Hello Everyone!I have view called vw_maintenance which holds records for maintenace of a car from two different tables. maintenance view has fields like ( branchname, vehicle id, mileage, last service date, next service date).I need to run query which displays the branchname from vw_maintenance which has maximum number of maintenance entries...Please help guys..I am stuck... |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-12-09 : 12:52:11
|
[code]SELECT TOP 1 branchnameFROM(SELECT COUNT() OVER (PARTITION BY branchname) AS Cnt,branchnameFROM Table)tORDER BY Cnt DESC [/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|