We help IT Professionals succeed at work.
Get Started

conditional From statemetn

d0nMaTTi
d0nMaTTi asked
on
353 Views
Last Modified: 2010-08-05
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?
Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE