Get column name, first record name

Discussion in 'ASP .Net' started by Leszek, Jan 19, 2005.

  1. Leszek

    Leszek Guest

    Hello!
    Can someone help me?

    How to get for some records (like 0 or 1) column names?

    Example:
    I've got a table, that looks

    server | parameter1 | parameter2 | parameter3
    ----------------------------------------------
    server1 | 0 | 0 | 1
    server2 | 1 | 0 | 1
    server3 | 1 | 1 | 0

    I want to have all with 0 value:

    server | parameter
    ---------------------
    server1 | parameter1
    server1 | parameter2
    server2 | parameter2
    server3 | parameter3

    So i need first record from each row and column name for it.
    Can someone help me? Please...
    I started with .NET in this week...
     
    Leszek, Jan 19, 2005
    #1
    1. Advertisements

  2. It's an sql question. Following select will do.

    select server, 'parameter1' as parameter from myTable where parameter1=0
    union
    select server, 'parameter2' as parameter from myTable where parameter2=0
    union
    select server, 'parameter3' as parameter from myTable where parameter3=0

    Eliyahu

    "Leszek" <> wrote in message
    news:OjKsi8f$...
    > Hello!
    > Can someone help me?
    >
    > How to get for some records (like 0 or 1) column names?
    >
    > Example:
    > I've got a table, that looks
    >
    > server | parameter1 | parameter2 | parameter3
    > ----------------------------------------------
    > server1 | 0 | 0 | 1
    > server2 | 1 | 0 | 1
    > server3 | 1 | 1 | 0
    >
    > I want to have all with 0 value:
    >
    > server | parameter
    > ---------------------
    > server1 | parameter1
    > server1 | parameter2
    > server2 | parameter2
    > server3 | parameter3
    >
    > So i need first record from each row and column name for it.
    > Can someone help me? Please...
    > I started with .NET in this week...
    >
    >
     
    Eliyahu Goldin, Jan 19, 2005
    #2
    1. Advertisements

  3. Leszek

    Leszek Guest

    Thank you very much!
    I thought, tha i must look into row, check each value, get the first record,
    column name for this value and put it into a table :)


    U¿ytkownik "Eliyahu Goldin" <> napisa³ w
    wiadomo¶ci news:efp8GNg$...
    > It's an sql question. Following select will do.
    >
    > select server, 'parameter1' as parameter from myTable where parameter1=0
    > union
    > select server, 'parameter2' as parameter from myTable where parameter2=0
    > union
    > select server, 'parameter3' as parameter from myTable where parameter3=0
    >
    > Eliyahu
    >
    > "Leszek" <> wrote in message
    > news:OjKsi8f$...
    >> Hello!
    >> Can someone help me?
    >>
    >> How to get for some records (like 0 or 1) column names?
    >>
    >> Example:
    >> I've got a table, that looks
    >>
    >> server | parameter1 | parameter2 | parameter3
    >> ----------------------------------------------
    >> server1 | 0 | 0 | 1
    >> server2 | 1 | 0 | 1
    >> server3 | 1 | 1 | 0
    >>
    >> I want to have all with 0 value:
    >>
    >> server | parameter
    >> ---------------------
    >> server1 | parameter1
    >> server1 | parameter2
    >> server2 | parameter2
    >> server3 | parameter3
    >>
    >> So i need first record from each row and column name for it.
    >> Can someone help me? Please...
    >> I started with .NET in this week...
    >>
    >>

    >
    >
     
    Leszek, Jan 19, 2005
    #3
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?SnVzdGlu?=

    Retrieving Record Key while creating the record.

    =?Utf-8?B?SnVzdGlu?=, Oct 4, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    825
    =?Utf-8?B?SnVzdGlu?=
    Oct 5, 2004
  2. Ken Varn
    Replies:
    1
    Views:
    1,093
    Ken Varn
    Aug 19, 2005
  3. ding feng
    Replies:
    2
    Views:
    3,242
    ding feng
    Jun 25, 2003
  4. Guest
    Replies:
    7
    Views:
    907
    Walter Wang [MSFT]
    Jun 28, 2006
  5. =?Utf-8?B?ZGF2aWQ=?=
    Replies:
    0
    Views:
    1,718
    =?Utf-8?B?ZGF2aWQ=?=
    Mar 12, 2007
  6. Josh Behl
    Replies:
    3
    Views:
    193
    Imtiaz Hussain
    Oct 29, 2003
  7. Richard Schneeman
    Replies:
    16
    Views:
    780
    Daniel Bush
    Aug 27, 2008
  8. Tim Chase
    Replies:
    7
    Views:
    486
    Dennis Lee Bieber
    Jul 20, 2012
Loading...