My data is layed out in three tables as follows:
I hope someone can understand what I am trying to achieve.
Best regards
SW
TableCo1
DATE ACC_CODE AMOUNT DESCRIPTN
20120801 412 100.00 Test entry
TableCo2
DATE ACC_CODE AMOUNT DESCRIPTN
20120801 412 100.00 Test entry
RefTable1
CO_CODE ACC_CODE ACC_NAME
Co1 412 Buildings
Co2 412 Cleaning
I need to join table 1 and 2 and add a new column called "COMPANY" and Co1 and Co2 in the field but I also want to join ACC_NAME as well.
So far I have this statement working to join the Table1 and Table2
select *, 'Co1' AS COMPANY
from TableCo1
UNION ALL
select *, 'Co2' AS COMPANY
from TableCo2
I just need the above code amended so that the follow appears in one query:
ConsolTable
DATE ACC_CODE AMOUNT DESCRIPTN ACC_NAME COMPANY
20120801 412 100.00 Test entry Building Services Co1
20120801 412 100.00 Test entry Cleaning Co2
I hope someone can understand what I am trying to achieve.
Best regards
SW
Last edited: