Cross-row computing in Java application development
In Java application development, ordered or cross-row computation based on database is oftenly involved, such as the last three, the previous one of the current record, the top five, the last but one, and the ranking of a certain record.
For instance,to find out the monthly growth rate of contract values for each sales man in 2012 in a Contract table. We need to firstly group by salesman, group by year within each group, group by month for each year and summarize, and lastly, perform the inter-row computation between the current month and its previous month.
We often use SQL to deal with it, but SQL does not offer any direct support for the algorithm related to sequence number. The problem is easy to solve since most ResultSet classes of JDBC support row number, and a few ones which doesn’t support can reload the class by itself. As we all know that there is another solution to the poor portability, such as the rownum in Oracle.
Do you have any better solutions?
Re: Cross-row computing in Java application development