Home > Back-end > Compute A table column total value, the total value in the table B to find matching records to calcu
Compute A table column total value, the total value in the table B to find matching records to calcu
Time:09-17
Possible titles do not describe clearly, then see detailed description here, thank you, If A table data is like this: Name department annual month salary out score Sname Dname cbYear cbMonth MonthPay Score Score_1 Office 2017 7 4500 50 45 Office 2017 8 4800 50 49 A purchase 46 families and 2017 9 4800 50 B procurement 44 families 2017 7 4500 50 B procurement division 2017 8 4500 50 40 B procurement 49 families and 2017 9 4600 50 Financial room 2017 9 3900 50 48 c . And so on,
B table data is like this: Score points calculation performance coefficient Lscore Plevel 150 1 140 0.9130 0.7. And so on, -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Performance pay 5% according to the monthly salary paid The sum (Score_1) or sum (MonthPay) is the where (cbMonth=7 or 8 or cbMonth=cbMonth=9) The problem is this: If 140 & lt; The sum (Score_1) 150 or less is calculated quarterly performance-based pay sum (MonthPay) * 0.05 * 1 If 130 & lt; The sum (Score_1) 140 or less is calculated quarterly performance-based pay sum (MonthPay) * 0.05 * 0.9 If 120 & lt; The sum (Score_1) 130 or less is calculated quarterly performance-based pay sum (MonthPay) * 0.05 * 0.7 . And so on,
According to table A sum (Score_1) value to B table matching calculate the coefficient of performance???????
Thank you again,
CodePudding user response:
Or, how to solve in Delphi, the teacher can also give a train of thought,
CodePudding user response:
On a post http://bbs.csdn.net/topics/392251990 Mention how to sum (Score_1) to find the corresponding calculation Plevel performance coefficient,
SELECT Plevel FROM B WHERE ABS (Lscore - sum (Score_1))=(SELECT MIN (ABS (Lscore - sum (Score_1))) FROM B WHERE Lscore & lt; The sum (Score_1))
But the total score of each name sum (Score_1) is different, have no way to distinguish between,,,
CodePudding user response:
. Are you hiring unit not,,,, tested, the algorithm is as follows: Select sname 'name', The sum (score_1) as' total scores, Isnull ((select plevel from B where lscore - sum (score_1) & gt;=0 and lscore - sum (score_1) & lt; 10), 0) as' coefficient ', The Sum (MonthPay) * 0.05 * isnull ((select plevel from B where lscore - Sum (score_1) & gt;=0 and lscore - sum (score_1) & lt; 10), 0) as' performance pay ' From A ls group by sname
CodePudding user response:
Excuse me, which IS not the final, so
Select sname 'name', The sum (score_1) as' total scores, Isnull ((select plevel from a where clause lscore - sum (score_1) & gt;=0 and lscore - sum (score_1) & lt; 10), 0) as' coefficient ', The Sum (MonthPay) * 0.05 * isnull ((select plevel from a where clause lscore - Sum (score_1) & gt;=0 and lscore - sum (score_1) & lt; 10), 0) as' performance pay ' The from group b by sname