I am using the following query on a .mdb file with the following results.
SELECT tableA.id, tableA.type, tableA.date, SUM(tableA.val) AS total, tableB.SumB
FROM tableA LEFT JOIN tableB ON tableB.id = tableA.id
GROUP BY tableA.id, tableA.type, tableA.date, tableB.SumB ;
results:

I need only the first record from the group of records with the same type and date.
I would use DISTINCT but the problem is that I have a different field (in this example id).
Any suggestions?
Thanks
P.S. Case 2:
Ids are the same for the red records but we have an additional column ‘name’ with different string values.
Use min of id and remove it from Group by clause