Skip to content
Advertisement

Extract the record for last hour for specific date

I am trying to extract the last hour (TKT_DT) record for number of tickets (TKT_DN) from sales table (PS_TKT_HIST) for specific date (BUS_DAT).

I have the following code but it extracts the number of tickets (TKT_NO) for each hour. I want to filter the last hour only. Here is the code I used:

I get the flowing results

I want to get only the record (4) for the last hour (21)

Advertisement

Answer

If you just want the number of tickets in the last hour on a given day:

For any hour other than the last hour (let’s say, the 9PM hour):

If by “last hour” you don’t mean 11 PM but rather the last hour there was a sale, you would have to do something like this:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement