Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Calculating Yield Expand / Collapse
Author
Message
Posted Monday, October 22, 2012 3:43 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, July 16, 2014 6:31 AM
Points: 100, Visits: 332
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')

Post #1375757
Posted Wednesday, October 24, 2012 12:40 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, July 16, 2014 6:31 AM
Points: 100, Visits: 332
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)

Post #1376631
Posted Wednesday, October 24, 2012 2:44 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, July 16, 2014 6:31 AM
Points: 100, Visits: 332
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.
Post #1376681
Posted Wednesday, October 24, 2012 4:25 PM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 6:36 PM
Points: 3,564, Visits: 7,701
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.
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?

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1376715
Posted Wednesday, October 24, 2012 4:28 PM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 6:36 PM
Points: 3,564, Visits: 7,701
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.
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?

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1376718
Posted Monday, October 29, 2012 2:00 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, July 16, 2014 6:31 AM
Points: 100, Visits: 332
thanks Luis.
Post #1378450
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse