SELECT id,
end
AS datey, 'E' FROM union_dev WHEREend
> NOW()
UNION
SELECT
CASE
WHENstr
>prs
THEN id
WHENstr
<prs
THEN id
WHENstr
IS NULL ANDprs
IS NULL THEN id
END,
CASE
WHENstr
>prs
THENstr
WHENstr
<prs
THENprs
WHENstr
IS NULL ANDprs
IS NULL THEN '0000-00-00'
END AS datey,
CASE
WHENstr
>prs
THEN 'S'
WHENstr
<prs
THEN 'P'
WHENstr
IS NULL ANDprs
IS NULL THEN 'N'
END
FROM union_dev
WHEREend
< NOW() ORend
IS NULL
ORDER BY datey DESC;
Hilft das?