Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
sqlfresher2k7
Aged Yak Warrior
623 Posts |
Posted - 2015-02-21 : 09:29:08
|
I need a query to get non null value..I can do with case statement but I want to know if IIF,Coalesce or CHOOSE will work.Student-------Sno Subject1 Subject2--- ------- -------1 English Null2 Null Science3 Social NUllExpected Results:-----------------Sno Subject1 --- ------- 1 English 2 Science3 Social Note:Each record for the subject1 and subject2 will have One Null and a value but it cannot have both Values..Thanks for your help in advance.. |
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2015-02-21 : 09:32:11
|
what if both subjects have values? |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2015-02-22 : 11:49:44
|
SELECT sNo, COALSCE(Subject1, Subject2)FROM dbo.Sample Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA |
|
|
viggneshwar
Yak Posting Veteran
86 Posts |
Posted - 2015-02-24 : 04:41:37
|
SELECT sNo, isnull(Subject1, Subject2)FROM dbo.SampleRegardsViggneshwar A |
|
|
|
|
|