Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

Help in select query - where clause

$
0
0
Hi,

I have a table and need to return one reocrd. In my case, I have a strange requirement. If the resulting row's one columns is null, then should return second row's column alone in first row.

-----------------
|ID | Name|Group|
|----------------
| 1 | A | G1    |
| 2 | B | G2    |
| 3 | C | G3    |
-----------------

For example if row 1 Name(A) is null, it should return B but entire data should be from row 1 only.

select Name, Group from table1 where id = 1
results in A, G1

If Name of row 1(A) is null then result should be B, G1.

Can you help me on this please?

Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>