By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,998 Members | 2,837 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,998 IT Pros & Developers. It's quick & easy.

Get column name, first record name

P: n/a
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...
Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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" <ma***@zegarek.pl> wrote in message
news:Oj**************@TK2MSFTNGP11.phx.gbl...
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...

Nov 19 '05 #2

P: n/a
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" <re*************@monarchmed.com> napisał w
wiadomo¶ci news:ef**************@tk2msftngp13.phx.gbl...
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" <ma***@zegarek.pl> wrote in message
news:Oj**************@TK2MSFTNGP11.phx.gbl...
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...


Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.