I don't think of any better way.
What I am trying to do is grab some data from table where the field childitem="NL"
and the complex part in selecting fields to show is that, I need to make new field Consumption
but this field value will be same childqty
but when the field processname
first 2 character is SC, I need to make the Consumption value to a childqty
of another field: current father
(4-SCF-329...[id:30]) is child
to another father
(4-FCM-3290...[id:17]) which is indeed child
to another father
(4-MCS-329....[id:21])
My Query:
SELECT tblBom.processname AS Process,
tblBom.child AS [SAP Code],
tblBom.childname AS Material,
iif(LEFT(tblBom.processname,2)="SC",
(SELECT childqty FROM tblBom WHERE tblBom.child like (SELECT father FROM tblBom WHERE child Like tblBom.father)),
tblBom.childqty
) AS consumption,
tblBom.childrate AS [Landed Rate],
tblBom.childrate * tblBom.childqty As RATE
FROM tblBom
WHERE tblBom.childitem Like "NL";
I want the tblBom.father
last in the 5th line of code to be the main Queries father. Is there a way to make it as variable somewhere or any way. If I change it to "4-SCF*" that will work.
- Orange: Condition checking for word "SC"
- Yellow: The value that need to be replaced
- Green: The value that will be placed on the yellow
- ReddishPink: The path to Green value for query