0
I have 3 tables:
aircraft(id_aeronvave, registration); occurrence(id_occurrence, data_utc); aeronave_occurrence(id_aeronave_occurrence, id_aircraft, id_occurrence)
I have this list of aircraft by groups of dates:
SELECT
o.data_utc,
listagg(a.matricula, ', ') within group (order by a.matricula)
FROM
aeronave a
JOIN aeronave_ocorrencia ao ON a.id_aeronave = ao.id_aeronave
JOIN ocorrencia o ON ao.id_ocorrencia = o.id_ocorrencia
GROUP BY o.data_utc
How do you find out how many aircraft with equal license plates are within 2 months? Calculating this for every date I have in my database.
Example:
data_utc = 11/08/2020 | matricules = PPTTN, PATAR | qtd_repeated aeronaves_1 = 1
data_utc = 20/07/2020 | matricules = PPTTN, PTABC | qtd_repeated aeronaves_1 = 1
I don’t know if I understood it correctly but it wouldn’t be the COUNT aggregation function associated with the GROUP BY enrollment clause and the range in the WHERE clause?
– anonimo
You speak aircraft aggregation count in range ?
– Motta
Exactly. But this calculation is based on the data_utc records that you have in my database.
– Otávio
Would it be a recurrent or possible consultation ? Recurring I would make an aggregate table loaded via job , eventual a virtual table generated by your select , in both cases a Join with itself testing the rule of months.
– Motta
Possibly even consultation.
– Otávio