I need some help to perform the following actions in MS Access with a SQL query.
The operations I would like to perform are illustrated in the following example:
Initial tables
TABLE A
Name H1 H2 H3
A 5 10 5
B 1 2 3
C 7 3 1
TABLE B:
Name H1 H2 H3
1 1 1 1
2 2 2 2
1) First step: Results
NAME TABLE A NAME TABLE B H1 H2 H3
A 1 4 9 4
A 2 3 8 3
B 1 0 1 2
B 2 1 0 1
C 1 6 2 0
C 2 5 1 1
So, the first row of this new table is calculated as the ABSOLUTEVALUE( TABLE A (row A)-TABLE B(row1)), the second row of this table would be ABSOLUTEVALUE( TABLE A (row A)-TABLE B(row2)) and so on.
2) Second step: Results
NAME TABLE A NAME TABLE B H1 H2 H3 Total
A 1 4 9 4 17
A 2 3 8 3 14
B 1 0 1 2 3
B 2 1 0 1 2
C 1 6 2 0 8
C 2 5 1 1 7
So in this step, I will need to add a field whis is calculated as the sum of values H1, H2 and H3 of each row
3) Final step: Results
Name H1 H2 H3
A 3 8 3
B 1 0 1
C 5 1 1
And in the final step, we select those A, B & C rows from the previous table in which the field Total has the minimum value.
Thanks!