Die vorherigen Antworten sollten beide funktionieren. Ich hätte noch eine dritte im Angebot:
Code:
SELECT
outerAP.KdNr,
(
SELECT FIRST 1 TelefonNr
FROM Ansprechpartner AS innerAP
WHERE innerAP.KdNr = outerAP.KdNr
ORDER BY (
CASE
WHEN innerAP.Standard THEN 1
ELSE 2
END
),
innerAP.ID DESC
) AS TelefonNr,
(
SELECT FIRST 1 FaxNr
FROM Ansprechpartner AS innerAP
WHERE innerAP.KdNr = outerAP.KdNr
ORDER BY (
CASE
WHEN innerAP.Standard THEN 1
ELSE 2
END
),
innerAP.ID DESC
) AS FaxNr
FROM Ansprechpartner AS outerAP
GROUP BY outerAP.KdNr;