December 5, 2008 at 12:27 am
hey Guys,
How can i set flag 1 and 0 for alternate rows using sql query?
your help is appreciated...
Id......Code....................Language.......Description................Flag
------------------------------------------------------------------------
1.......Heating Cables......... German.......Heizbänder/Heizkabel.....1
......................................Russian.......??????? ??????..............1
......................................English........Heating Cables..............1
2.......Heating Panels......... German.......Heizbänder/Heizkabel......0
......................................Russian.......??????? ??????...............0
..................................... English........Heating Cables...............0
3.......Trnsformers............. German.......Heizbänder/Heizkabel.......1
..................................... Russian.......??????? ??????................1
......................................English........Heating Cables................1
4.......TT3000.................. German........Heizbänder/Heizkabel........0
..................................... Russian........??????? ??????................0
..................................... English.........Heating Cables...............0
i Hope this gives u clear idea about my requirement...
December 5, 2008 at 1:19 am
Try something like this
SELECT * , ROW_NUMBER() OVER (ORDER BY ID) % 2 AS AlternatingFlag
FROM SomeTable
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
December 5, 2008 at 2:40 am
Hey Guys...
i got it....
Thanks
December 6, 2008 at 7:13 pm
If you didn't use Gail's solution, would you mind posting your solution, please?
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply