need help again
SELECT inmast.fpartno, inmast.fdescript, inmast.fleadtime,inmast.fcpurchase
FROM M2MDATA01.dbo.inmast inmast
WHERE (inmast.fleadtime>0)
order by inmast.fpartno
then after it got that i tried a case statement that said this:
SELECT inmast.fpartno, inmast.fdescript, inmast.fleadtime,inmast.fcpurchase,
case inmast.fcpurchase
when 'y' then invend.fvendno
else 'make'
end
FROM M2MDATA01.dbo.inmast inmast,invend
WHERE (inmast.fleadtime>0)
order by inmast.fpartno
with this code the vendno is just some random vendno from the table. it doesn't get the vendno that is corresponding with the partno. so then i tried a subquery inside my case statement like this:
SELECT inmast.fpartno, inmast.fdescript, inmast.fleadtime,inmast.fcpurchase,
case inmast.fcpurchase
when 'y' then (select invend.fvendno from invend,inmast where inmast.fpartno = invend.fpartno)
else 'make'
end
FROM M2MDATA01.dbo.inmast inmast,invend
WHERE (inmast.fleadtime>0)
order by inmast.fpartno
part that gives me an error that says:
Server: Msg 512, Level 16, State 1, Line 1
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
so my subquery is returning to many values. i tried the same code but instead of comparing the fcpurchase field i did the fpartno field saying:
case inmast.fpartno
when invend.fpartno then fvendno
this would work if i gave a specific partno like '20571':
case inmast.fpartno
when '20571' then fvendno
so if any of you are following along with this all i want this query to do is display all the parts in the inmast table that have leadtimes greater than 0 and then if they are puchase items show the vendno from the invend table.i thought my case statements would work but for some reason the one isn't connecting the two partno's and the other the subquery returns to many values
any ideas are much appreciated.
hopefully this is clearer than my last post, if you need me to clear up anything just post it and i'll do my best
jb

