Subject | SQL - what am I doing wrong |
---|---|
Author | zlatko.ivankovic |
Post date | 2011-09-30T08:59Z |
for following SQL
select
( select case when (a.mdz is null) then 'A'
when (cast(a.mdz as timestamp) > cast('2011-09-30' as timestamp)) then 'B'
when (cast(a.mdz as timestamp) < cast('2011-09-30' as timestamp)) then 'C'
else 'D'
end
from (
select max(KEStazZap.stazzapdatumzaposljavanja) as mdz
from KEStazZap
where KEStazZap.DjelatnikID = KEDjelatnik.DjelatnikID
and cast( '2011-09-30' as timestamp) <= cast(KEStazZap.stazzapdatumprekida as timestamp)
group by djelatnikID
) a
)
from
KEDjelatnik
in results I get Null values where I think it should be 'A'. What am I doing wrong ?
Regards,
Zlatko
select
( select case when (a.mdz is null) then 'A'
when (cast(a.mdz as timestamp) > cast('2011-09-30' as timestamp)) then 'B'
when (cast(a.mdz as timestamp) < cast('2011-09-30' as timestamp)) then 'C'
else 'D'
end
from (
select max(KEStazZap.stazzapdatumzaposljavanja) as mdz
from KEStazZap
where KEStazZap.DjelatnikID = KEDjelatnik.DjelatnikID
and cast( '2011-09-30' as timestamp) <= cast(KEStazZap.stazzapdatumprekida as timestamp)
group by djelatnikID
) a
)
from
KEDjelatnik
in results I get Null values where I think it should be 'A'. What am I doing wrong ?
Regards,
Zlatko