November 13, 2005 at 5:39 am
Hallo everybody,
i have an syntax error in this Statement.
Server: Msg 156, Level 15, State 1, Line 40
Incorrect syntax near the keyword 'else'.
Plaese Help.
SELECT distinct t1.personalnummer,t1.agentname,t1.eintrittsdatum,
t1.datum,t1.code,
case t1.start_moment
when ((SELECT min(t3.stop_moment)
FROM svtemp T3
WHERE (t3.personalnummer=t1.personalnummer)
AND t3.start_moment =t1.start_moment) )
then (SELECT min(t3.stop_moment)
FROM svtemp T3
WHERE (t3.personalnummer=t1.personalnummer)
AND t3.start_moment =t1.start_moment)
when ((SELECT min(t3.start_moment)
FROM svtemp T3
WHERE (t3.personalnummer=t1.personalnummer)
AND t3.start_moment =t1.stop_moment) )
then (SELECT min(t3.start_moment)
FROM svtemp T3
WHERE (t3.personalnummer=t1.personalnummer)
AND t3.start_moment =t1.stop_moment)
else t1.start_moment
end as start_moment,
case t1.stop_moment
when ((SELECT min(t3.start_moment)
FROM svtemp T3
WHERE (t3.personalnummer=t1.personalnummer)
AND t3.stop_moment =t1.stop_moment) )
then (SELECT min(t3.start_moment)
FROM svtemp T3
WHERE (t3.personalnummer=t1.personalnummer)
AND t3.stop_moment =t1.stop_moment)
when ((SELECT max(t3.stop_moment)
FROM svtemp T3
WHERE (t3.personalnummer=t1.personalnummer)
AND t3.start_moment =t1.stop_moment) )
then ((SELECT max(t3.stop_moment)
FROM svtemp T3
WHERE (t3.personalnummer=t1.personalnummer)
AND t3.start_moment =t1.stop_moment)
else t1.stop_moment
end as stop_moment,
t1.groupid
FROM svtemp T1 JOIN svtemp T2 ON (t1.personalnummer=t2.personalnummer)
group by t1.personalnummer,t1.agentname,t1.eintrittsdatum,
t1.datum,t1.code,t1.groupid,T1.START_MOMENT,T1.STop_MOMENT
regards
Thomas
November 13, 2005 at 6:44 am
Thanks,
i ve found it 🙂
It was an (( in the last then
Thomas
November 13, 2005 at 9:43 am
Cool... thanks for posting back to save us time.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply