troubleshooting Question

conditional From statemetn

Avatar of d0nMaTTi
d0nMaTTiFlag for Finland asked on
Microsoft SQL Server 2005
3 Comments1 Solution354 ViewsLast Modified:
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_clientversion=1 or statindex-table
if workstations.w_clientversion = 3.
Both tables (stat and statindex) have same structure.

I tried to run following select-clause :

select workstations.w_id,workstations.w_name,workstations.w_clientversion,
(select max(s_started) from (
case workstations.w_clientversion
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
appari

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros