October 22, 2012 at 3:43 pm
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')
October 24, 2012 at 12:40 pm
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)
October 24, 2012 at 2:44 pm
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.
October 24, 2012 at 4:25 pm
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))
October 24, 2012 at 4:28 pm
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.
October 29, 2012 at 2:00 pm
thanks Luis.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply