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 |
mohan123
Constraint Violating Yak Guru
252 Posts |
Posted - 2013-01-31 : 03:05:33
|
Hello all ,Here i am facing some issue i'm not getting any push to move on or this one exists i am joining data from Three tables A,B and CA.ID B.Name C.Description 1 ram good2 mohan Average3 charan good4 rohan Average5 tareni good6 chinta Averagehere in my query i am using distinct top 2 ID so that i am getting 2 results now i just want to get distinct description top2 with out id is that possible ??select distinct top 2 A.ID B.Name C.Description from table i need to get only distinct C.Description rest of the should neeed to be there but main one is C.DescriptionP.V.P.MOhan |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-01-31 : 04:14:42
|
[code]SELECT your columns....FROM(SELECT your current columns...,DENSE_RANK() OVER (ORDER BY descriptionField) AS SeqFROM...... your existing query)tWHERE Seq<=2[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|