#In enterprise ERP, each employee has multiple qualification certificates. Qualification certificates have types, names and registration times, as well as change time and end time. Attribute; Now there is a requirement. When employees check their own information in the system: Qualification certificates of the same type, the same name, and the same registration time will be displayed, whichever has the latest change time, and the rest will not be displayed.
Data source: SAP production system obtained through RPC;
Text
The following is the main structure of the table ( There may be a replacement phenomenon on the mobile phone display):
If you add a mark to the latest record in this place, for example, add a field to display x, use sql when filtering It is very convenient to get the results directly. I asked my SAP development colleagues: no;
思路
The code is not novel, I just want to talk about my ideas (there may be some problems):
1. First, use the MySQL statement GROUP BY to group the results of the three fields; group Result: Divide the data into groups according to the requirements. The data in each group is changed according to the time. The latest one is at the top (that is, the one that meets the requirements is at the top)
2. Java The code gets the data set and processes it;
3. As mentioned above, the first item meets the requirements, so it traverses the data set. For each group of data sets, use the characteristics of List to set all elements. For the same elements, remain consistent with the first item;
4. Remove duplication;
This small requirement is achieved in a simple way;
Summary
To summarize in simple words,
1. Group first, and the grouped data are arranged in descending order of time;
2. Then use Java code to process the List, and The elements of the list are set to the same value by traversing;
3. Remove duplicates from the list;
[Recommended course: MySQL Tutorial]
The above is the detailed content of MySQL statements and Java code implement on-demand filtering of corporate employee qualification certificates. For more information, please follow other related articles on the PHP Chinese website!