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 |
jhnroze
Starting Member
1 Post |
Posted - 2010-12-22 : 04:17:43
|
how do i write this in sql with the following criterianote:its always three values since im only getting the top 3criteria :rowsp1p2p3or p3p2p1ans:get p2criteriarowsp1p2p1orrowsp2p1p1orrowsp1p1p2ans:get the common p1 |
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-12-22 : 04:49:50
|
quote: Originally posted by jhnroze how do i write this in sql with the following criterianote:its always three values since im only getting the top 3criteria :rowsp1p2p3or p3p2p1ans:get p2
Use row_number function and take the second one. It will get you p2 for whatever order by you doquote: criteriarowsp1p2p1orrowsp2p1p1orrowsp1p1p2ans:get the common p1
Use count method and display the id having maximum count. |
 |
|
|
|
|