SQL to get first and last records from the recordset
Posted on 2007-10-14
I need some quick help in writing the query. This should be strictly done in SQL and cannot be done in PL/SQL or cannot create sequence number (Only select access).
The query should be order by
- CLAIM_TYPE descending
After the data is sorted/ordered base on the above, summarize the financial fields:
For the below records, use the values in the LAST record within the unique key for the following fields:
For the remaining non-Financial fields, use the values in the FIRST record within the unique key. These fields include:
Below is the initial query to get the exact totals:
GROUP BY AUDIT_NBR, DETAIL_NBR)
The final select statement should include all the above mentioned columns.
Please let me know if anything is not clear or need additional information.
I am giving the maximum points.