Total qty of a CTE BOM query

I got it figured out (finally)

I needed a cast as decimal(10,20) to keep the lengths the same. so on the CTE level I needed a calculated field

cast(PartMtl.QtyPer as decimal(20,10))

and on the Union all level, I needed

cast((CTE.Calculated_StartQty * PartMtl1.QtyPer)as decimal(20,10))

now it works.

Lots of google searching. Seems I’m not the only one that’s had this problem.

3 Likes

Hi Knash,

Your code works great, but I have a dobut, in this part of the code:
" Where dbo.PartRev.Approved = 1 " How can I do to get me the JOIN for the parts from the last revision whether or not it is approved?

Regards.

Welcome Jona,

This code has been updated over the years. check out this thread.

if you get stuck start a new thread and tag me. Just that way your issue won’t get lost in an old thread.

OK Let me check, Thanks for the reply.

Regards.

Thanks Knash, I resolved my problem in base with your example code.

Regards.