SQL Server Performance

flags for Alternate Rows

Discussion in 'General Developer Questions' started by linok29, Dec 4, 2008.

  1. linok29 New Member

    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...
  2. Adriaan New Member

    The flag looks perfectly meaningless ...
    If your ID values are numeric and sequential, then you can use an expression:
    (invid % 2) AS FLAG
  3. atulmar New Member

    or generate new row number column using row_number() function, and do the same as Adriaan did.
  4. TommCatt New Member

    [quote user="linok29"]i Hope this gives u clear idea about my requirement...[/quote]
    Not in the least.
    • Why are there 12 rows but only 4 have id values?
    • Why do you have useless information? Except for the Code attribute, all the data repeats the same values.
    • Just what exactly are you trying to accomplish?

Share This Page