I have two tables I would like to join.
Table A
Date | Hour | Direction | Qty
2018-11-20 1 DE/UK 2
2018-11-20 2 DE/UK 6
Table B
Date | Hour | Area | Price
2018-11-20 1 DE 5
2018-11-20 2 DE 4
2018-11-20 1 UK 3
2018-11-20 2 UK 9
I want to join them like this:
Table C
Date | Hour | Direction | Qty | AreaFrom | AreaTo | PriceFrom | PriceTo | Profit
2018-11-20 1 DE/UK 2 DE UK 5 3 3-5 = -2
2018-11-20 2 DE/UK 6 DE UK 4 9 5
I have tried by CROSS Join and other kinds of joins, but have not been able to make it work.
Other related questions I have looked at so far: