Home > database >  May I have a PL/SQL algorithm implementation issues
May I have a PL/SQL algorithm implementation issues

Time:10-25

If there is a table, the record is as follows:
ID DNO AMT
1 AA2 5
1 AA1 10
2 AA1 10
2 AA3 6
3 AA1 10
3 AA3 6

Now need to obtain the following results (ID value under the condition of only once, the sum of the AMT, the largest and DNO record to complete, such as AA3 in two rows, then either all, or don't take) :
ID DNO AMT
1 AA2 5
2 AA3 6
3 AA3 6

This kind of situation with PL/SQL method to realize the simple point?

CodePudding user response:

Your results as descriptions of the result is not consistent with you,
Is each ID, AMT the smallest line?

CodePudding user response:

reference 1st floor minsic78 response:
results if you and your description of the results are not consistent,
Is each ID, AMT the smallest line?

I'm sorry, I didn't clearly stated, in front of the what I mean is:
Result set, ID value under the condition of only once, make each different DNO corresponding AMT and maximum, such as I want to get the results of the above, the AA2 AMT has a value of 5, AA3 AMT value is 6, so that they two DNO AMT value and for 5 + 6=11 (DNO the same line of AMT value must be the same), and take the result set DNO record to complete, such as AA3 in two rows, then either all, or are not, in the above example, if you take DNO=AA1 record, you must remove the ID=1, 2, 3, can no longer take DNO=AA2 and AA3 recorded, because ID in the result set to repeat, but then he AMT and value is 10, so not the optimal solution

CodePudding user response:

Don't see you from the list of results sets out the rules of, description is not clear

Result set, ID value under the condition of only once, make each different DNO corresponding AMT and maximum, such as I want to get the results of the above, the AA2 AMT has a value of 5, AA3 AMT value is 6, so that they two DNO AMT value and for 5 + 6=11 (DNO the same line of AMT value must be the same), and take the result set DNO record to complete, such as AA3 in two rows, then either all, or are not, in the above example, if you take DNO=AA1 record, you must remove the ID=1, 2, 3, can no longer take DNO=AA2 and AA3 recorded, because ID in the result set to repeat, but then he AMT and value is 10, so not the optimal solution

CodePudding user response:

See dizzy, don't know what you want as a result,

CodePudding user response:

Large amount of data?
  • Related