K
Kiran
Table : Production
Ln Processor Date_Worked
1 Abhisekh 3/31/2009
2 Abhisekh 3/31/2009
3 Abhisekh 3/31/2009
4 Abhisekh 3/31/2009
5 Abhisekh 3/31/2009
6 Bindu 3/31/2009
7 Bindu 3/31/2009
8 Bindu 3/31/2009
9 Bindu 3/31/2009
10 Mahesh 3/31/2009
11 Mahesh 3/31/2009
12 Mahesh 3/31/2009
13 Mahesh 3/31/2009
14 Mahesh 3/31/2009
15 Mahesh 3/31/2009
16 Bindu 4/1/09
17 Bindu 4/1/09
18 Bindu 4/1/09
19 Bindu 4/1/09
20 Mahesh 4/1/09
21 Mahesh 4/1/09
22 Mahesh 4/1/09
23 Mahesh 4/1/09
24 Mahesh 4/1/09
25 Mahesh 4/1/09
Table : Quality
Processor Score
Abhisekh 92
Bindu 89
Mahesh 95
Criteria
Quality < 90 100 % Loans to be checked
Quality 90-95 80 % Loans to be checked
Quality >95 50 % Loans to be checked
The resources have the Quality Score mentioned in the Quality; I need to
select the number of records to be checked from Production table based on the
above criterion. This needs to be done everyday based on their production
yesterday. After the Loans are checked the Quality Scores would be updated. I
need a query to select the records from the Production Table. I am using the
below mentioned query to get the result. However the query takes a very long
time. Is there a way to simplify this.
SELECT P1.ln, P1.Processor, Quality.Score
FROM Reports AS P1 INNER JOIN Quality ON P1.Processor=Quality.Processor
WHERE (((P1.ln) In (Select Top 50 Percent P2.Ln from Reports P2 where
((P2.Processor = P1.Processor) and (P2.Date_Worked = [Please Enter the
date])) order by P2.Ln)) AND ((Quality.Score)>"95")) OR (((P1.ln) In (Select
Top 80 percent P2.Ln from Reports P2 where ((P2.Processor = P1.Processor) and
(P2.Date_Worked = [Please Enter the date])) order by P2.Ln)) AND
((Quality.Score) Between "90" And "95")) OR (((P1.ln) In (Select Top 100
Percent P2.Ln from Reports P2 where ((P2.Processor = P1.Processor) and
(P2.Date_Worked = [Please Enter the date])) order by P2.Ln)) AND
((Quality.Score)<"90"));
Ln Processor Date_Worked
1 Abhisekh 3/31/2009
2 Abhisekh 3/31/2009
3 Abhisekh 3/31/2009
4 Abhisekh 3/31/2009
5 Abhisekh 3/31/2009
6 Bindu 3/31/2009
7 Bindu 3/31/2009
8 Bindu 3/31/2009
9 Bindu 3/31/2009
10 Mahesh 3/31/2009
11 Mahesh 3/31/2009
12 Mahesh 3/31/2009
13 Mahesh 3/31/2009
14 Mahesh 3/31/2009
15 Mahesh 3/31/2009
16 Bindu 4/1/09
17 Bindu 4/1/09
18 Bindu 4/1/09
19 Bindu 4/1/09
20 Mahesh 4/1/09
21 Mahesh 4/1/09
22 Mahesh 4/1/09
23 Mahesh 4/1/09
24 Mahesh 4/1/09
25 Mahesh 4/1/09
Table : Quality
Processor Score
Abhisekh 92
Bindu 89
Mahesh 95
Criteria
Quality < 90 100 % Loans to be checked
Quality 90-95 80 % Loans to be checked
Quality >95 50 % Loans to be checked
The resources have the Quality Score mentioned in the Quality; I need to
select the number of records to be checked from Production table based on the
above criterion. This needs to be done everyday based on their production
yesterday. After the Loans are checked the Quality Scores would be updated. I
need a query to select the records from the Production Table. I am using the
below mentioned query to get the result. However the query takes a very long
time. Is there a way to simplify this.
SELECT P1.ln, P1.Processor, Quality.Score
FROM Reports AS P1 INNER JOIN Quality ON P1.Processor=Quality.Processor
WHERE (((P1.ln) In (Select Top 50 Percent P2.Ln from Reports P2 where
((P2.Processor = P1.Processor) and (P2.Date_Worked = [Please Enter the
date])) order by P2.Ln)) AND ((Quality.Score)>"95")) OR (((P1.ln) In (Select
Top 80 percent P2.Ln from Reports P2 where ((P2.Processor = P1.Processor) and
(P2.Date_Worked = [Please Enter the date])) order by P2.Ln)) AND
((Quality.Score) Between "90" And "95")) OR (((P1.ln) In (Select Top 100
Percent P2.Ln from Reports P2 where ((P2.Processor = P1.Processor) and
(P2.Date_Worked = [Please Enter the date])) order by P2.Ln)) AND
((Quality.Score)<"90"));