I have the table A
conipk contittle concycle ttlid
122786 108405 S13 107552
122787 108405 S13 107552
122788 108405 S13 107552
122789 108405 S13 107552
Table b
conipk contype concile conamt
122786 LU N 5.000
122786 LU N 7.000
122787 LU N 1.000
122788 LU N 3.000
122788 LU N 1.000
122789 LU N 1.000
I want the 3 columns and the first record from table B.
The result desired is
conipk contittle concycle ttlid contype concile conanmt
122786 108405 S13 107552 LU N 5
122787 108405 S13 107552 LU N 1
122788 108405 S13 107552 LU N 3
122789 108405 S13 107552 LU N 1
I did the query
SELECT
rc.contype, rc.concile, rc.conamtt, c.conipk, c.concycle, c.ttlid
FROM
Contract c
LEFT JOIN
(SELECT TOP 1
r.conipk, r.contype, r.concile, r.conamt
FROM
rules r
JOIN
contract c2 ON r.conipk = c2.conipk) AS rc ON rc.conipk = c.conipk
But I just get the first record.
Thanks in advance