d0nMaTTi
asked on
conditional From statemetn
My purpose is select w_id and w_name -fields from workstations table
and the latest date (s_started) from stat -table if workstations.w_clientversi on=1 or statindex-table
if workstations.w_clientversi on = 3.
Both tables (stat and statindex) have same structure.
I tried to run following select-clause :
select workstations.w_id,workstat ions.w_nam e,workstat ions.w_cli entversion ,
(select max(s_started) from (
case workstations.w_clientversi on
when 1 then [stats] else [statindex] end)) as latestdate
from workstations
but i got an following error message:
'Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'case'.'
Is it anyhow possible to constitute conditional from -clause using case when structure?
and the latest date (s_started) from stat -table if workstations.w_clientversi
if workstations.w_clientversi
Both tables (stat and statindex) have same structure.
I tried to run following select-clause :
select workstations.w_id,workstat
(select max(s_started) from (
case workstations.w_clientversi
when 1 then [stats] else [statindex] end)) as latestdate
from workstations
but i got an following error message:
'Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'case'.'
Is it anyhow possible to constitute conditional from -clause using case when structure?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank's for answers.
Both works fine
Both works fine
select workstations.w_id, workstations.w_name, workstations.w_clientversi
case workstations.w_clientversi
else (select max(s_started) from [statindex]) end as latestdate
from workstations