I have the following query.
with getstock as
(
select
a.bomparent, a.bomchild, a.bomqty, a.bompos, a.baltmethod, a.bomissue
from
bom a
where
bomparent = 'QZ10-0262601' and baltmethod = '1'
union all
select
parent.bomparent, parent.bomchild, parent.bomqty, parent.bompos, parent.baltmethod, parent.bomissue
from
getstock as a
inner join
bom as parent, stock as s on parent.bomparent = a.bomchild
where
parent.baltmethod = '1' and parent.bomparent = s.stocknum
)
select *
from getstock
When I run it, I get the following error.
Msg 102, Level 15, State 1, Line 9
Incorrect syntax near ','.
Where is the issue?