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 |
sp3010
Starting Member
8 Posts |
Posted - 2007-12-27 : 00:56:37
|
Table having 3 col name wono,assetid,date.wono assetid date25001 10001 19-Jan-0725002 10002 20-Jan-0725003 10003 20-Jan-0725004 10002 21-Jan-0725005 10003 22-Feb-0725006 10002 22-Feb-07I want that query will sort the record on count of assetid & show resutls as following25002 10002 Date25004 10002 do25006 10002 do25003 10003 do25005 10003 do25001 10001 doPlease help |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2007-12-27 : 01:12:59
|
SELECT t1.wono,t1.assetid,t1.dateFROM Table t1INNER JOIN (SELECT assetid,COUNT(*) AS 'RecCount' FROM Table GROUP BY assetid) t2ON t2.assetid = t1.assetidORDER BY t2.RecCount DESC,t1.wono ASC |
 |
|
sp3010
Starting Member
8 Posts |
Posted - 2007-12-27 : 02:02:10
|
Thanks visakhIt works. |
 |
|
sp3010
Starting Member
8 Posts |
Posted - 2007-12-27 : 02:51:49
|
Thanks visakhIt works. |
 |
|
Jeff Moden
Aged Yak Warrior
652 Posts |
Posted - 2007-12-31 : 01:01:24
|
I'm really happy that you guys understand each other... there's no way that I would have gotton "do" as a date...--Jeff Moden |
 |
|
|
|
|