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 |
|
shakthiA
Starting Member
12 Posts |
Posted - 2009-10-16 : 04:25:01
|
| Hi I want to select always two rows from our tables on top besides the results that I get from my search. I was doing some thing like below code if I want to have one row from our tables on top results. Now I need to change this for 2 rows which could not done with UNION and two Case statements. SELECT * FROM ( SELECT ROW_NUMBER() OVER (ORDER BY CASE WHEN S.ID = '4ed975f8' THEN 0 ELSE 1 END, (SELECT Rank FROM #tmpLangs WHERE Lang = S.Language COLLATE SQL_Latin1_General_CP1_CI_AS) DESC,S.CreationDate DESC) AS Row, S.Language, S.ID AS 'PubId' FROM SHELF S , Featured FP WHERE FP.ID = P.ID AND S.Audience = 'Public' )AS FeaturedPubsWHERE Row BETWEEN 1 AND 10Any Ideas Please help me.Thanks |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-10-16 : 05:26:34
|
SELECT TOP 2 * FROM...or waht do you mean? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
shakthiA
Starting Member
12 Posts |
Posted - 2009-10-16 : 06:23:45
|
Sample Output I want to have like :Row Lang PubId Title1 en 4ed975f8 dddddd2 70066abc 10.15.20093 ba738703 bentley4 ccccccc test test5 de bbbbbbb yamiNow it returns for me like below:Row Lang PubId Title1 en 4ed975f8 dddddd2 ba738703 bentley3 70066abc 10.15.20094 ccccccc test test5 de bbbbbbb yamiIf I want to have always this second document next to the first one I need to have a script to select the both documents first and then others. Thanks.quote: Originally posted by webfred SELECT TOP 2 * FROM...or waht do you mean? No, you're never too old to Yak'n'Roll if you're too young to die.
|
 |
|
|
|
|
|