A
arran1180
table 1 has 2 records of $100 on 1st Jan (primkey is "Ikey", eg 245 and 246))
table 2 has 1 record of $100 on 1st Jan (primkey is "PBKey" eg PB60001)
Currently my qeury uses the cash amout and the date from table 2 to match
the table 1 data twice, i want my query to only match one of these records -
ie no dupes of primary keys used! this example can happen either way round -
sometimes table 2 will have more similar records... I know that my solution
involves the DISTINCT keyword, but it is just the primary keys i want to be
distinct on each table. currently my SQL is :
SELECT DISTINCT tbl_CSFB_PB_tmp.*, qry_CSFB_PB_ImagineTotalsAmended.*
FROM tbl_CSFB_PB_tmp INNER JOIN qry_CSFB_PB_ImagineTotalsAmended ON
Abs(tbl_CSFB_PB_tmp.SumofCashAmount-qry_CSFB_PB_ImagineTotalsAmended.ICash)<0.01
And (tbl_CSFB_PB_tmp.SettlementDate)=(qry_CSFB_PB_ImagineTotalsAmended.Date);
I am very new to SQL so apologies if this is an obvious one!
table 2 has 1 record of $100 on 1st Jan (primkey is "PBKey" eg PB60001)
Currently my qeury uses the cash amout and the date from table 2 to match
the table 1 data twice, i want my query to only match one of these records -
ie no dupes of primary keys used! this example can happen either way round -
sometimes table 2 will have more similar records... I know that my solution
involves the DISTINCT keyword, but it is just the primary keys i want to be
distinct on each table. currently my SQL is :
SELECT DISTINCT tbl_CSFB_PB_tmp.*, qry_CSFB_PB_ImagineTotalsAmended.*
FROM tbl_CSFB_PB_tmp INNER JOIN qry_CSFB_PB_ImagineTotalsAmended ON
Abs(tbl_CSFB_PB_tmp.SumofCashAmount-qry_CSFB_PB_ImagineTotalsAmended.ICash)<0.01
And (tbl_CSFB_PB_tmp.SettlementDate)=(qry_CSFB_PB_ImagineTotalsAmended.Date);
I am very new to SQL so apologies if this is an obvious one!