|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
if..else problem
Can someone help me?
I have this query Code: select * from KA_STAN_ZABEZPIECZEN as jeden Where data = (SELECT DISTINCT MAX(data) from KA_STAN_ZABEZPIECZEN as dwa Where jeden.nazwastacji = dwa.nazwastacji) and dc ='0' I want to use If..Else for every column in my table. It contains 50 columns. I know that i must create 50 if..else. But how to make one? I have a criteria for returning values. For example: if first_column_value >1 then else first_column_value <1 I made this Code: Use sms_k3a select * from KA_STAN_ZABEZPIECZEN as jeden Where data = (SELECT DISTINCT MAX(data) from KA_STAN_ZABEZPIECZEN as dwa Where jeden.nazwastacji = dwa.nazwastacji and ms = '1') if KA_STAN_ZABEZPIECZEN.auditbaseobjects = '1' begin PRINT 'The following dc are excellent mod_cook books:' PRINT ' ' select * from KA_STAN_ZABEZPIECZEN as jeden Where data = (SELECT DISTINCT MAX(data) from KA_STAN_ZABEZPIECZEN as dwa Where jeden.nazwastacji = dwa.nazwastacji and dc = '1') End else if KA_STAN_ZABEZPIECZEN.auditbaseobjects = '0' begin select * from KA_STAN_ZABEZPIECZEN as jeden Where data = (SELECT DISTINCT MAX(data) from KA_STAN_ZABEZPIECZEN as dwa Where jeden.nazwastacji = dwa.nazwastacji and ms = '1') end sms_k3a is the name of database, KA_Stan_Zabezpieczen is the name of table and DC, nazwastacji and auditbaseobjects are the names of columns. |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft SQL Server > if..else problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|