Can someone help me?
I have this query
Code:select *
from KASTANZABEZPIECZEN as jeden
Where data = (SELECT DISTINCT MAX(data)
from KASTANZABEZPIECZEN 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 firstcolumnvalue >1 then
else firstcolumnvalue <1
I made this
Code:Use smsk3a
select *
from KASTANZABEZPIECZEN as jeden
Where data = (SELECT DISTINCT MAX(data)
from KASTANZABEZPIECZEN as dwa
Where jeden.nazwastacji = dwa.nazwastacji and ms = '1')
if KASTANZABEZPIECZEN.auditbaseobjects = '1'
begin
PRINT 'The following dc are excellent modcook books:'
PRINT ' '
select *
from KASTANZABEZPIECZEN as jeden
Where data = (SELECT DISTINCT MAX(data)
from KASTANZABEZPIECZEN as dwa
Where jeden.nazwastacji = dwa.nazwastacji and dc = '1')
End
else
if KASTANZABEZPIECZEN.auditbaseobjects = '0'
begin
select *
from KASTANZABEZPIECZEN as jeden
Where data = (SELECT DISTINCT MAX(data)
from KASTANZABEZPIECZEN as dwa
Where jeden.nazwastacji = dwa.nazwastacji and ms = '1')
end
smsk3a is the name of database, KAStan_Zabezpieczen is the name of table and DC, nazwastacji and auditbaseobjects are the names of columns.
No one has replied yet! Why not be the first?
Sign in or Join us (it's free).