Advertisement

07.24.2008 at 12:33AM PDT, ID: 23591266
[x]
Attachment Details

conditional From statemetn

Asked by d0nMaTTi in SQL Server 2005

Tags: Microsoft, SQLServer 2005, CASE WHEN if From-statement, T-SQL

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?Start Free Trial
 
Loading Advertisement...
 
[+][-]07.24.2008 at 12:39AM PDT, ID: 22076807

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: SQL Server 2005
Tags: Microsoft, SQLServer 2005, CASE WHEN if From-statement, T-SQL
Sign Up Now!
Solution Provided By: appari
Participating Experts: 2
Solution Grade: B
 
 
[+][-]07.24.2008 at 12:40AM PDT, ID: 22076812

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.24.2008 at 12:55AM PDT, ID: 22076881

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628