I have two codes that i would like to join to get a total. Below code does the calculation correctly:
Code:
SELECT N.OrderID,
N.DeliveryNo,
N.PlantIDScion,
N.PlantIDRoot,
N.TreePrice,
N.DeliveryQuantity,
N.sRL2Pay,
N.rRL2Pay,
Round(N.TreePrice + IIf(N.sRL2Pay, 1, 0) + IIf(N.rRL2Pay, N.TreePrice * 0.20, 0), 2) AS FinalPricePerTree,
Round(N.DeliveryQuantity * (N.TreePrice + IIf(N.sRL2Pay, 1, 0) + IIf(N.rRL2Pay, N.TreePrice * 0.20, 0)), 2) AS TotalLinePrice,
"R" & Format(N.TreePrice, '0.00')
& " + sR" & Format(IIf(N.sRL2Pay, 1, 0), '0.00') & " R"
& " + r%" & Format(IIf(N.rRL2Pay, 20, 0), '0.00') & ", L" AS FullBreakdown
FROM
TblNursOrders AS N
WHERE
N.DeliveryNo IS NOT NULL;
Sample data:
Code:
OrderID DeliveryNo PlantIDScion PlantIDRoot TreePrice DeliveryQuantity sRL2Pay rRL2Pay FinalPricePerTree TotalLinePrice FullBreakdown
0 INV-2514 AP0572 AP0388 128,00 530 Yes Yes 154,6 81938 R128,00 + sR1,00 R + r%20,00, L
FinalPrice columns needs to be in code below:
HTML Code:
SELECT N.OrderID, N.DeliveryNo, N.PlantIDScion, N.PlantIDRoot, SP.PlantType AS Fruit, N.OrderSize, PR.SizeFactor, N.TreePrice, N.DeliveryQuantity, N.sRL2Pay, N.rRL2Pay, Round( (N.TreePrice * Nz(PR.SizeFactor,1.0)) + IIf(N.sRL2Pay, Nz(PR.SurchargePerTree,0),0) + IIf(N.rRL2Pay, N.TreePrice * Nz(PR.RootLevyPct,0)/100,0) ,2) AS FinalPricePerTree, Round( N.DeliveryQuantity * ( (N.TreePrice * Nz(PR.SizeFactor,1.0)) + IIf(N.sRL2Pay, Nz(PR.SurchargePerTree,0),0) + IIf(N.rRL2Pay, N.TreePrice * Nz(PR.RootLevyPct,0)/100,0) ) ,2) AS TotalLinePrice, "R" & Format(N.TreePrice * Nz(PR.SizeFactor,1.0),'0.00') & " + sR" & Format(IIf(N.sRL2Pay, Nz(PR.SurchargePerTree,0),0),'0.00') & " + r%" & Format(IIf(N.rRL2Pay, Nz(PR.RootLevyPct,0),0),'0.00') AS FullBreakdownFROM ( ( TblNursOrders AS N INNER JOIN Plants AS SP ON N.PlantIDScion = SP.PlantID ) INNER JOIN Plants AS RP ON N.PlantIDRoot = RP.PlantID ) LEFT JOIN TblPriceRules AS PR ON (SP.PlantType = PR.Fruit) AND (N.OrderSize BETWEEN PR.MinSize AND PR.MaxSize)WHERE N.DeliveryNo IS NOT NULLORDER BY SP.PlantType, N.OrderSize, N.DeliveryQuantity DESC;I get the join expression not supported error
Sample data
Code:
Nr Fruit OrderDate SCult SClone SSource SCert RCult RClone RSource RCert Agent OrderAmount Allocated Nursery OrderBy Gebied sRL2Pay rRL2Pay TreePrice Select Comment OrderSize CertifiedType DeliveryNo DeliveryDate DeliveryQuantity DeliveryType PayableTo Anno sRoyLev rRoyLev
3349 Appel 26/01/2024 Bingo Gala BI 1701 G.778 CB 17 Topfruit GV - Buccleuch 6 000,00 40 Redhill Superplant Nursery (Pty) Ltd Leon Irene -1 -1 R126,00 0 R126,00 + sR0,00 R + r%20 R DN059 06/08/2024 40 Sonja Lucas t/a Ruby Boerdery 24 sR0,00 R r%20 R