Combining multiple condition in single case statement in Sql Server -


According to the following statement, let me know a case ... ed statement in SQL Server

  If PAT_ENT.SCR_DT is not empty and PAT_ENTRY.ELIGIBILITY is zero, then please help me fulfill the following condition for a complex  case ... END  statement. If display PAT_ENT.SCR_DT is not empty and PAT_ENTRY.EL is equal, then display 'error' if PAT_ENTRY.EL is yes and if DS.DES is equal to zero or off, then display 'Active' if DS.DES  

Thank you in advance.

You can place the condition after the WHEN section, such as: < / P> Select

  when PAT_ENT.SCR_DT is not empty and PAT_ENTRY.ELIGIBILITY is zero 'favor' WHEN PAT_ENT.SCR_DT is not empty and PAT_ENTRY.EL = 'no' then 'error' when PAT_ENTRY. EL = 'yes' and ISNULL (DS. DES, 'off') = 'OFF' then 'active' when DS DES = 'N' then 'Initial Period' when the DS DES = 'Y' then 'complete' to end ....  

Of course, it can be argued that such complex rules are in your business logic level, stored in the database The operating system is not in ...


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -