|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
hi,
my question is about using coalesce function in SQLServer. This function brings up the first not null value. my problem is i cannot get the corresponding field name. this is what i use SELECT COALESCE(Stop1, Stop2, Stop3, ...., Stop10) FROM ... WHERE ProjectID = #URL.ProID# it returns, (no column name) ---------------- 1 somebody@somthing.com the fields in the DB goes like stop1, stop2, stop3,... so, i need to get which stop i am .thanks in advance. |
|
#2
|
|||
|
|||
|
Code:
SELECT COALESCE(Stop1, Stop2, Stop3, ...., Stop10), case when stop1 is not null then 'Stop1' when stop2 is not null then 'Stop2' ... end as whichColumn Why repeating columns? Indicates some design flaw. |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > coalesce function |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|