How to retrieve several fields from table b
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 fields 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
No comments:
Post a Comment