jeudi 21 novembre 2019

How to test COUNT missing hours and show the results as some sort of array?

I have a set list of PKs that should have 24 hourly records everyday. Some days are missing hours. Is there any way to identify which hours are missing and log them in the results in some sort of array?

Here are the list of available PKs with examples DimGeneratorPK - ex.23,62,63,89 DimDatePK - 20190101, 20190102, 20190103. it is sequential DimHourPK - 1,2,3,4,5,6....24 DimMonthPK - 20190101, 20190201, 20190501. Only the month value moves, the days are always 01.

I can do select count(DimHourPK) from CalcTableExample where DimMonthPK = '20190801' and DimGeneratorPK = 1619

for one generator, and I see 744. That makes sense because August has 31 days * 24 hours in a day. Is it possible to have the results show as an array with all my possible DimGeneratorPKs in one sweep. Then a Temp column that possibly lists some information pertaining to the missing DimHourPKS that are missing from that Month or whatever date range you choose.

Thank!

Aucun commentaire:

Enregistrer un commentaire