Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Calculating Yield


Calculating Yield

Author
Message
kabaari
kabaari
SSC-Enthusiastic
SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)

Group: General Forum Members
Points: 106 Visits: 365
Hi all,

I'm running into an issue calculating yield.
;with totalcount as (
select
cast(count(sn) as decimal) as total
from completedUnit
)
select
(100 - (cast(count(distinct sn) as decimal)/(select * from totalcount))*100) as 'yield'
from productiondefect



The following works however, I need to group weekly and by operator

This does not work

;with totalcount as (
select
cast(count(sn) as decimal) as total
from completedUnit
)
select
(100 - (cast(count(distinct sn) as decimal)/(select * from totalcount))*100) as 'yield'
from productiondefect
where sn = (select c.sn
from completedUnit as c
join productiondefect as d on c.sn = d.sn
where c.operator = 'Operator')


kabaari
kabaari
SSC-Enthusiastic
SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)

Group: General Forum Members
Points: 106 Visits: 365
Ok. I got the below to run. The formula returns weekly defects / overall production totals. I want to calculate weekly defect / weekly production. Is this possible?

;with totalcount as (
select
cast(count(sn) as decimal) as total
from completedUnit
where MONTH(dateentered) = '10' and operator = 'operator'

)
select
(100 - (cast(count(distinct d.sn) as decimal)/(select * from totalcount))*100) as 'yield'
from productiondefect as d
join completedUnit as c on d.sn = c.sn
where MONTH(c.dateentered) = '10' and c.operator = 'operator'
GROUP BY DATEADD(wk, DATEDIFF(wk, 7, c.dateentered), 7)
ORDER BY DATEADD(wk, DATEDIFF(wk, 7, c.dateentered), 7)


kabaari
kabaari
SSC-Enthusiastic
SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)

Group: General Forum Members
Points: 106 Visits: 365
Below are my results:

yield
94.4000000000000000
97.6000000000000000
98.4000000000000000
96.8000000000000000

Now, I need to get rid of the zeros and show dates.
Luis Cazares
Luis Cazares
SSCrazy Eights
SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)

Group: General Forum Members
Points: 8582 Visits: 18157
kabaari (10/24/2012)
Below are my results:

yield
94.4000000000000000
97.6000000000000000
98.4000000000000000
96.8000000000000000

Now, I need to get rid of the zeros and show dates.


You should do formatting on the front end.
But if you must do it here, an easy way is
CAST( yield AS decimal( 3,1))




Luis C.
General Disclaimer:
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?


How to post data/code on a forum to get the best help: Option 1 / Option 2
Luis Cazares
Luis Cazares
SSCrazy Eights
SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)

Group: General Forum Members
Points: 8582 Visits: 18157
kabaari (10/24/2012)
Ok. I got the below to run. The formula returns weekly defects / overall production totals. I want to calculate weekly defect / weekly production. Is this possible?



To help you, we need to know more about this. You should provide DDL and sample data.
You can read how to post it and obtain better responses in the article linked in my signature.


Luis C.
General Disclaimer:
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?


How to post data/code on a forum to get the best help: Option 1 / Option 2
kabaari
kabaari
SSC-Enthusiastic
SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)

Group: General Forum Members
Points: 106 Visits: 365
thanks Luis.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search