I have a Price table related to part number where each part could have prices from different vendors ... the price table was set up with an active flag, Vendor and buy and sell prices. I made a query which creates a distinct record of 2 buy and sell costs plus the minimum between them so it has 6 costs all together but am finding this is extremly slow ... without making the price table into a flat file with all 6 possible prices is there a better way to associated this data?
Part# Buy$ Sell$ Vendor
A 10 12 X
A 9 11 Y
Query
Part# B1 S1 B2 S2 MB MS
A 10 12 9 11 9 11
The query is used by a screen which can be toggled between
Vendor X, Y or Minimum ... The intent is that at some point there could be more vendors added so I am trying to minimize rebuilding logic surrounding these prices
I am using the following query;
SELECT DISTINCT x.part, Nz((SELECT A.buy FROM Price A WHERE A.part=x.part AND A.vendor="X" and a.active=true),-1) AS wBuy, Nz((SELECT A.Sell FROM Price A WHERE A.part=x.part AND A.vendor="X" and a.active=true),-1) AS wSell, Nz((SELECT A.buy FROM Price A WHERE A.part=x.part AND A.vendor="Y" and a.active=true),-1) AS bBuy, Nz((SELECT A.sell FROM Price A WHERE A.part=x.part AND A.vendor="Y" and a.active=true),-1) AS bSell, Nz((fMin(wBuy,bBuy)),0) AS mBuy, Nz((fMin(wSell,bSell)),0) AS mSell
FROM part AS x
WHERE (((x.part)=getglobal("Part")));
Part# Buy$ Sell$ Vendor
A 10 12 X
A 9 11 Y
Query
Part# B1 S1 B2 S2 MB MS
A 10 12 9 11 9 11
The query is used by a screen which can be toggled between
Vendor X, Y or Minimum ... The intent is that at some point there could be more vendors added so I am trying to minimize rebuilding logic surrounding these prices
I am using the following query;
SELECT DISTINCT x.part, Nz((SELECT A.buy FROM Price A WHERE A.part=x.part AND A.vendor="X" and a.active=true),-1) AS wBuy, Nz((SELECT A.Sell FROM Price A WHERE A.part=x.part AND A.vendor="X" and a.active=true),-1) AS wSell, Nz((SELECT A.buy FROM Price A WHERE A.part=x.part AND A.vendor="Y" and a.active=true),-1) AS bBuy, Nz((SELECT A.sell FROM Price A WHERE A.part=x.part AND A.vendor="Y" and a.active=true),-1) AS bSell, Nz((fMin(wBuy,bBuy)),0) AS mBuy, Nz((fMin(wSell,bSell)),0) AS mSell
FROM part AS x
WHERE (((x.part)=getglobal("Part")));