Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have 3 tables that I want to merge into one:
- Initial Stock: ItemID / Shop / Stock
- Movements: ItemID / Shop / Date / Received / Sent
- Sales : ItemID / Shop / Date / Sales
Both Movements and Sales only matter when there's initial stock, so I want to left join them both into Initial Stock. But when I use the second left join (loading Sales) it uses Movement's Date as a parameter too, and leaves out the sales that were made in days with no movements.
If I could join Sales without taking Date into account it would work out.
Is there a way to achieve this?
Thanks in advance.
I think I wouldn't join these tables else just concatenate them, maybe with something like this:
table:
load 'Initial' as Source, ItemID, Shop, '2019/01/01' as Date, Stock as Amount from A;
load 'Movements' as Source, ItemID, Shop, Date, rangesum(Received, -Sent) as Amount from B;
load 'Sales' as Source, ItemID, Shop, Date, -Sales as Amount from C;
whereby it's not mandatory to synchronize the different amount-fields - an unsynchronized table would also work - but with it it will be easier within the UI.
- Marcus