I have two tables in SQL Server where there is a discrepancy between some of the values for grouping purposes.
The tables look like this:
A B C D E
JA HOB Sell Dec24 10.00
JA HOB Buy Dec24 11.00
MQ HOB Sell Dec24 12.00
MQ HOB Buy Dec24 13.00
A B C D E
JA HOB Sell Jul24 10.10
JA HOB Buy Jul24 11.20
MQ HOB Sell Dec24 12.30
MQ HOB Buy Dec24 13.40
I need to create the following output:
A B C D E E2
JA HOB Sell Dec24 10.00 10.10
JA HOB Buy Dec24 11.00 11.20
MQ HOB Sell Dec24 12.00 12.30
MQ HOB Buy Dec24 13.00 13.40
I need to group by columns A-D, but as you can see from the tables the dates do not match (which I have no control over). For the most part the dates will match, but there are some instances where this is not the case and I am not sure how to account for it. Excluding the date in the group would not be an option because there will be multiple duplicates of values for columns A-C.
Is there a relationship I can create between the two tables to ensure that I can join the right values and create the expected output? or is there a better way to go about it?
1