Suppose we are using DPMO system of quality and if a person has done 100 points and the opportunity is 9 and the person has got 10 qfails out of 70 as 70 transaction got selected for quality audit, then what would be the formula of measuring his quality by DPMO system ? 10 errors , 100 transactions , 9 opportunity per transaction, transaction QC'd 70?
DPMO = (1,000,000 * number of defects)/(number of units * number of opportunities)
What does that give you?
Related
I have a set of inventory data where the amount increases at a given rate. For example, the inventory increases by ten units every day. However, from time to time there will be an inventory reduction that could be any amount. I need a query that can find me the most recent inventory reduction and return to me the sum of that deduction.
My table holds date and amount for numerous item id's. In theory what I am trying to do is select all amounts and dates for a given item ID, and then find the difference between the most recent reduction between two days inventory. Due to the fact that multiple items are tracked, there is no guarantee that the id column will be consecutive for a set of items.
Researching to find a solution to this has been completely overwhelming. It seems like window functions might be a good route to try, but I have never used them and don't even really have a concept of where to start.
While I could easily return the amounts and do the calculation in PHP, I feel the right thing to do here is harness SQL but my experience with more complex queries is limited.
ID | ItemID | Date | Amount
1 2 2019-05-05 25
7 2 2019-05-06 26
34 2 2019-05-07 14
35 2 2019-05-08 15
67 2 2019-05-09 16
89 2 2019-05-10 5
105 2 2019-05-11 6
Given the data above, it would be nice to see a result like:
item id | date | reduction
2 2019-05-10 11
This is because the most recent inventory reduction is between id 67 and 89 and the amount of the reduction is 11 on May 10th 2019.
In MySQL 8+, you can use lag():
select t.*, (prev_amount - amount) as reduction
from (select t.*,
lag(amount) over (partition by itemid order by date) as prev_amount
from t
) t
where prev_amount > amount
order by date desc
limit 1;
I've created the database for library management system.
The Query is to be return for the question below !!!
Find fine payable(fine) against each student of particular department for past 6 months
Assumption: Fine amount is 2/day(either in cent or INR) and it'll double for the second day, likewise 2,4,8,16,32,64,128,256.......
my code for the question is:
SELECT
GROUP_CONCAT(s.id) AS IDs,
GROUP_CONCAT(DATEDIFF(returned,exp_date)) AS DAYS,
GROUP_CONCAT(POW(2,DATEDIFF(returned,exp_date))) AS FINE_PER_HEAD,
SUM(POW(2,DATEDIFF(returned,exp_date))) AS Fine,s.dept
FROM student s
INNER JOIN borrower b
ON s.id=b.id
WHERE returned>exp_date AND exp_date
BETWEEN DATE_SUB(NOW(), INTERVAL 6 MONTH) AND NOW()
GROUP BY s.dept;`
In the output i got 2^33 cent (33 days)in the fine Column Here,The Image contains the output screen of the result that i got from the query
IDs DAYS FINE_PER_HEAD Fine dept
----------------------------------------------------------------------------
1,36,138 2,5 4,32 36 CS
116,104,109,112 1,11,8,33 2,2048,256,8589934592 8589936898 Electronics
196 13 8192 8192 Maths
1,73,174 10,14 1024,16384 17408 Mechanical
1,48,150 6,5 64,32 96 Physics
How can i limit the fine amount that should not exceed the particular amount like < 5000 or 6000 cent> whatever , what should i do?
I am having difficulty trying to make a calculated field that I need. So here is what I am trying to do:
I have a query that combines the information based on three tables. The most important fields that for the application are as follows:
Family Income Age Patient
15,000 18 Yes
28,000 25 No
30,000 1 Yes
From here I want to make a calculated field that gives the correct program the patient was enrolled in. based on these fields ie:
Program Minimum Income Maximum Income Minimum Age Maximum Age Patient
Children's 0 20,000 1 19 Yes
Adult 0 12,000 19 65 No
Non Patient 0 20,000 1 19 No
Adult 2 12,000 50,000 19 65 No
Etc.
to create:
Family Income Age Patient Program
15,000 18 Yes Children's
28,000 25 No Adult 2
30,000 1 Yes Children's 2
I know I can use IIf to hard code it in to the field, but then it will be really difficult for other people to update the information as the guidelines change. Is it possible to have the information stored in a table? and use the information on the table form etc, or will I need to use IIf
Any Ideas? is it possible to dynamically create the IIf in SQL using VBA while pulling the information from the table?
EDIT:::
Thank you for your response and for formatting my tables, I still have no idea how you changed it, but it looks amazing!
I tried to add the SQL you added down below, but I was not able to make it work. I'm not sure if I made a mistake so I included the SQL of my Query. The query currently returns 0 values, so I think I messed something up. (The real Query is embarassing...I'm sorry for that). Unfortunately, I have done everything in my power to avoid SQL, and now I am paying the price.
SELECT qry_CombinedIndividual.qry_PrimaryApplicant.[Application Date],
qry_CombinedIndividual.qry_PrimaryApplicant.[Eligibility Rep],
qry_CombinedIndividual.qry_PrimaryApplicant.Name,
qry_CombinedIndividual.qry_PrimaryApplicant.Clinic,
qry_CombinedIndividual.qry_PrimaryApplicant.Outreach,
qry_CombinedIndividual.qry_PrimaryApplicant.[Content Type ID],
qry_CombinedIndividual.qry_PrimaryApplicant.[Application Status],
qry_CombinedIndividual.qry_PrimaryApplicant.Renewal,
qry_CombinedIndividual.qry_Enrolled.EthnicityEnr,
qry_CombinedIndividual.qry_Enrolled.GenderEnr, qry_CombinedIndividual.AgeAtApp,
qry_CombinedIndividual.[Percent FPL], tbl_ChildrensMedical.MinPercentFPL,
tbl_ChildrensMedical.MaxPercentFPL, tbl_ChildrensMedical.MinAge,
tbl_ChildrensMedical.MaxAge, tbl_ChildrensMedical.Program
FROM qry_CombinedIndividual
INNER JOIN tbl_ChildrensMedical ON qry_CombinedIndividual.qry_Enrolled.Patient = tbl_ChildrensMedical.Patient
WHERE (((qry_CombinedIndividual.AgeAtApp)>=[tbl_ChildrensMedical].[MinAge]
And (qry_CombinedIndividual.AgeAtApp)<[tbl_ChildrensMedical].[MinAge])
AND ((qry_CombinedIndividual.[Percent FPL])>=[tbl_ChildrensMedical].[MinPercentFPL]
And (qry_CombinedIndividual.[Percent FPL])<[tbl_ChildrensMedical].[MaxPercentFPL]));
Also there are many different programs. Here is the real Children's Table (eventually I would like to add adults if possible)
*Note the actual table uses FPL (which takes family size into account, but is used the same as income). I am again at a total loss as to how you formated the table.
Program Patient MinPercentFPL MaxPercentFPL MinAge MaxAge
SCHIP (No Premium) No 0 210 1 19
SCHIP (Tier 1) No 210 260 1 19
SCHIP (Tier 2) No 260 312 1 19
Newborn No 0 300 0 1
Newborn (Patient) Yes 0 300 0 1
Children's Medical Yes 0 200 1 19
CHIP (20 Premium) Yes 200 250 1 19
CHIP (30 Premium) Yes 250 300 1 19
Do I have the correct implementation for the table I have? Or should I be changing something. I can also send more information/sample data if that would help.
Thank you again!
I just created some tables with your sample data and used the following SQL. Your 3rd 'patient' doesn't match any of the ranges (Age 1, Income $30K)
SELECT tblPatient.PatName, tblPatient.FamInc, tblPatient.Age, tblPatient.Patient,
tblPatientRange.Program, tblPatientRange.MinInc, tblPatientRange.MaxInc, tblPatientRange.MinAge,
tblPatientRange.MaxAge, tblPatientRange.Patient
FROM tblPatient INNER JOIN tblPatientRange ON tblPatient.Patient = tblPatientRange.Patient
WHERE (((tblPatient.FamInc)>=[tblPatientRange]![MinInc] And (tblPatient.FamInc)<=[tblPatientRange]![MaxInc])
AND ((tblPatient.Age)>=[tblPatientRange]![MinAge] And (tblPatient.Age)<=[tblPatientRange]![MaxAge]));
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
I'm looking for a way to weight my results to get the "best" highest rated result.
I have a table consisting of rating (0-5), mentions and name.
I.E.
RATING MENTIONS NAME
2.5 15 Bob
4.4 14 Susan
1 60 John
5 2 Steve
Both mentions and rating are important so sorting by just rating won't get the desired results.
For this example; while Steve has the highest rating he has very little mentions so i'm not very confident that he is the "best" highest rated person. Susan has several mentions and a high rating so she should surpass Steve. John has a very low rating but lots of mentions, he should only surpass any of the other people if he has a ridiculous amount of mentions.
The ideal result would be something similar to
RATING MENTIONS NAME
4.4 14 Susan
5 2 Steve
2.5 15 Bob
1 60 John
Appreciate the help!
Simplest way to do this is
RATING * RATING * Mentions
Which would provide the following:
RATING MENTIONS NAME SCORE
2.5 15 Bob 93.75
4.4 14 Susan 271.04
1 60 John 60
5 2 Steve 50
It is a pretty simple way to 'weight' the value of the rating.
Obviously you can go more complex but I would think the above is sufficient and the Query is easy so I will let you try and work that out yourself if you like the method!
Obviously you can just add another RATING if you want a LOT of weight on the rating OR multiply it by a a fixed amount - but the squaring / POWER is key (you could try RATING ^ 2.5) (^ is POWER)
When I encounter this problem, I often take the approach of reducing the rating by one standard error. The formula for the standard error is:
standard deviation for the group / sqrt(group size)
If you had the standard deviation for each group, I would order them using:
order by (case when mentions > 1 then stdev / sqrt(mentions) end)
This is not as "punishing" as Evan Miller's suggestion (pointed to by Juergen). This is essentially taking a confidence interval more like 60% than 95%. Admittedly, my preference is a bit empirical (based on experience). However, there is an issue with multiple comparisons and you don't need to estimate the exact confidence interval -- you just need to know the relative ordering of them.
You can calculate the standard deviation using the function stdev().
Well, I'm not very good in statistic, but from your expected result, I believe you need to find the importance of each property.. Which one is more important than the other one, I think you can use equation below:
values = weight * RATING + (1-weight) * MENTIONS
You can play around with the weight value, till you got what you want.. For me 0.8 kind a make sense..
RATING MENTIONS NAME SCORE
4.4 14 Susan 6.32
2.5 15 Bob 5
5 2 Steve 4.4
1 60 John 2
I have an (example) application that sends baseball scores to users. The use is able to select which inning the score should be sent for some specific teams (e.g. 'Send me Yankee scores after 7 innings). There is also a setting for 'All other' teams (e.g. 'Send me scores for any other teams after 8 innings).
These settings are saved to a table which stores the user, a team ID, and the number of innings. Team ID '99' is used for 'All other teams'. So our user's records would look like:
**User - Team - Innings**
Bob - 13 (Yankees) - 7
Bob - 99 (all other teams) - 8
Now it comes time to check the scores and send some notifications. I find that the Yankees game has reached the end of the 7th inning and fire off a message to Bob.
20 minutes later, that same Yankees game has reached the 8th inning. Bob should NOT receive a message this time, since he got one after 7 innings.
Now consider Julie:
**User - Team - Innings**
Julie - 13 (Yankees) - 8
Julie - 99 (all other teams) - 7
Julie has used the settings to say 'send me all scores after 7 innings, except for Yankees scores which should wait until 8 innings'. This time, after 7 innings in the Yankees game, Julie should NOT receive a notification.
Finally, Dirk. Dirk is a little confused:
**User - Team - Innings**
Dirk - 13 (Yankees) - 7
Dirk - 99 (all other teams) - 7
His Yankees setting is pretty redundant, but whatever - as long as he doesn't receive the same notification twice, he's fine.
The Yankees game has just completed the 7th inning. What is the best way to query my table and decide who needs to get alerts?
I am fairly new to SQL, but I think I can make a plain-language representation:
Send alerts to:
Any people that care about the team A team after X innings, unless
they also care about ALL teams after < X innings (they would already
have received an alert)
PLUS
Any people that care about ALL teams
after X innings, unless they also care about team A after < X innings
(they would already have received an alert)
(I don't think this actually covers Dirk's scenario though?)
My best guess is that I need to make a WHERE clause that matches the team AND the innings, but then also tests if there is a record in the same table for the same user that meets the criteria above.
This is way beyond me - I don't even know what techniques to google. I couldn't even come up with a decent question title :/
Start by making a select that shows specific team settings plus general team settings. You can do that by joining the table on itself.
select s.*, g.innings as g_innings
from settings s join settings g
on (g.user = s.user and g.team = 99) -- 'g.team is null' would be better, yes...
The rest is easy: use this select twice with appropriate where clauses, and union the result.
EDIT: use a single query and OR the two where clauses.
select s.*, g.innings as g_innings
from settings s join settings g
on (g.user = s.user and g.team = 99) -- 'g.team is null' would be better, yes...
where (s.innings = X AND g.innings >= X)
OR (g.innings = X AND s.innings >= x)