Skip to content
Advertisement

Query to get the Average of ONLY the first occurrences

I have 2 tables like these:

Table Info

Table A

I need to take the first occurrence (occurrency_date ordered asc) of each Info and subtract from when the Info was created (created_date), after that take the average between them

Something like this:

I made many attempts but none were successful, how could I get this data?

Advertisement

Answer

If I understood your problem right, you just need to get the min(occurrency_date) of each info_id and with subquery get their crated_date:

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