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 |
|
sujithukvl@gmail.com
Starting Member
22 Posts |
Posted - 2009-03-18 : 03:20:56
|
| SELECT * FROM ( select row_number() over (order by Manufacture.ManufactureID) as Rec_num, ManufactureID FROM Manufacture WHERE DisplayLogoInSplashPage= 1)A where Rec_num%2=0This selects ManufactureID at evn position in table.SELECT * FROM ( select row_number() over (order by Manufacture.ManufactureID) as Rec_num, ManufactureID FROM Manufacture WHERE DisplayLogoInSplashPage= 1)A where Rec_num%2=1This selects ManufactureID at odd position in table.but I want both this in a single querry like select ManufactureID as ManufactureIDOdd if Rec_num%2=1and ManufactureID as ManufactureIDEven if Rec_num%2=0what can I do for this?……………………………………………………………………………………………………………………………………………………………..If taking postion using row_number() is difficult we may use ManufactureID%2 …………………………………………………………………………………………………………………………………………………………….. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-03-18 : 03:52:58
|
Like this?SELECT MAX(CASE WHEN recID % 2 = 0 THEN ManufactureID ELSE NULL END) AS evenManufactureID, MAX(CASE WHEN recID % 2 = 1 THEN ManufactureID ELSE NULL END) AS oddManufactureIDFROM ( SELECT ROW_NUMBER() OVER (ORDER BY ManufactureID) - 1 AS recID, ManufactureID FROM Manufacture WHERE DisplayLogoInSplashPage = 1 ) AS fGROUP BY recID / 2ORDER BY recID / 2 E 12°55'05.63"N 56°04'39.26" |
 |
|
|
sujithukvl@gmail.com
Starting Member
22 Posts |
Posted - 2009-03-19 : 02:15:12
|
| great great thanksi was affried that people understand my needBut u helped me |
 |
|
|
|
|
|