rgb192
asked on
The multi-part identifier "i.orderid" could not be bound.
SELECT
p.productid,p.title, (ISNULL(CAST(P_Cnt.prod_Cn t AS VARCHAR(20)), 'No Orders'))as aquantity,p.internalsku,p. internalsk u2,p.inter nalsku3,p. folderid,p .inwarehou se,p.inwar ehouse2,p. inwarehous e3,p.ourin warehouse, p.ourinwar ehouse2,p. ourinwareh ouse3,p.se ntquantity ,p.sentqua ntity2,p.s entquantit y3,p.estim atedcost,p .cost2,p.c ost3,date, date2,date 3,estimate ddate,esti mateddate2 ,estimated date3
from products p
left outer join (
select p2.productid, count(*) prod_Cnt from orderitems i
inner join orders o on o.orderid = i.orderid
right join payments y on o.orderid = y.orderid
inner join products p2 on i.productid = p2.productid
where o.statusid in (9,10,90,180,260)
group by p2.productid)
P_Cnt on p.productid = P_Cnt.productid
where p.folderid = 119 order by p.productid desc
works
but in select statement, when I want to display i.orderid
I get an error
SELECT
p.productid,p.title, (ISNULL(CAST(P_Cnt.prod_Cn t AS VARCHAR(20)), 'No Orders'))as aquantity,p.internalsku,p. internalsk u2,p.inter nalsku3,p. folderid,p .inwarehou se,p.inwar ehouse2,p. inwarehous e3,p.ourin warehouse, p.ourinwar ehouse2,p. ourinwareh ouse3,p.se ntquantity ,p.sentqua ntity2,p.s entquantit y3,p.estim atedcost,p .cost2,p.c ost3,date, date2,date 3,estimate ddate,esti mateddate2 ,estimated date3,i.or derid
from products p
left outer join (
select p2.productid, count(*) prod_Cnt from orderitems i
inner join orders o on o.orderid = i.orderid
right join payments y on o.orderid = y.orderid
inner join products p2 on i.productid = p2.productid
where o.statusid in (9,10,90,180,260)
group by p2.productid)
P_Cnt on p.productid = P_Cnt.productid
where p.folderid = 119 order by p.productid desc
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "i.orderid" could not be bound.
p.productid,p.title, (ISNULL(CAST(P_Cnt.prod_Cn
from products p
left outer join (
select p2.productid, count(*) prod_Cnt from orderitems i
inner join orders o on o.orderid = i.orderid
right join payments y on o.orderid = y.orderid
inner join products p2 on i.productid = p2.productid
where o.statusid in (9,10,90,180,260)
group by p2.productid)
P_Cnt on p.productid = P_Cnt.productid
where p.folderid = 119 order by p.productid desc
works
but in select statement, when I want to display i.orderid
I get an error
SELECT
p.productid,p.title, (ISNULL(CAST(P_Cnt.prod_Cn
from products p
left outer join (
select p2.productid, count(*) prod_Cnt from orderitems i
inner join orders o on o.orderid = i.orderid
right join payments y on o.orderid = y.orderid
inner join products p2 on i.productid = p2.productid
where o.statusid in (9,10,90,180,260)
group by p2.productid)
P_Cnt on p.productid = P_Cnt.productid
where p.folderid = 119 order by p.productid desc
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "i.orderid" could not be bound.
ASKER
is there any way to return rows of products table and orderitems table
the query currently only returns products table
>is there any way to return rows of products table and orderitems table
sure, you only have to define what "join"/relationship you want to apply for the query, aka what output you want.
I don't have a crystal ball, so you have to give some "specs"
sure, you only have to define what "join"/relationship you want to apply for the query, aka what output you want.
I don't have a crystal ball, so you have to give some "specs"
ASKER
i.orderid, i.productid from orderitems table table
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks
the question is: which row/value or orderid do you want to return?