Banderson
(Brandon Anderson)
December 28, 2017, 9:19pm
21
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
Jona
(Jonatan)
November 23, 2021, 10:17pm
22
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.
knash
(Ken Nash)
November 23, 2021, 10:27pm
23
Welcome Jona,
This code has been updated over the years. check out this thread.
I just made a few changes to show more like the grid you just posted.
[Screenshot 2021-06-22 171240]
/*
* Disclaimer!!!
* This is not a real query being executed, but a simplified version for general vision.
* Executing it with any other tool may produce a different result.
*/
with [JobAsmCTE] as
(select
[JobAsmbl].[JobNum] as [JobAsmbl_JobNum],
[JobAsmbl].[AssemblySeq] as [JobAsmbl_AssemblySeq],
[JobAsmbl].[PartNum] as [JobAsmbl_PartNum],
[JobAsmbl].[Parent] as [JobAsmbl_Parent],
…
if you get stuck start a new thread and tag me. Just that way your issue won’t get lost in an old thread.
Jona
(Jonatan)
November 23, 2021, 10:30pm
24
OK Let me check, Thanks for the reply.
Regards.
Jona
(Jonatan)
November 29, 2021, 5:02pm
25
Thanks Knash, I resolved my problem in base with your example code.
Regards.