I’m trying to write a SQL query for Oracle SQL in order to retrieve the last records for a certain period frequency. For example, say the frequency is Quarterly, (I’d also like monthly and annually to work), I can provide the start dates and end dates for the quarters if necessary, but I need to retrieve the last entry within each quarter. How can I do this? I’ve had limited luck so far without writing lots of subqueries.
Share
Try something like:
for months. (Use ‘Q’ or ‘Y’ instead of ‘MON’ in the
truncclause for quarters or years.)