Skip to content
Advertisement

Count records per month with condition

I have a table, let’s call them SUMMARYDATA

I need to SELECT(DEPARTMENT,MONTH,YEARS,COUNT(LATECOME)) and COUNT the records Count (where LATECOME > '00:00:01') > 2 in per month.

Because, Aria & Brian has LATECOME > 2 in per month, Belle & Ziya only 1 LATECOME, and Chloe Only 2 LATECOME in per month. So, in Department BB just 1 that is Aria, and Department CC is 0, because Chloe & Ziya <= 2 LATECOME.

And this is the sample output that I mean:

Advertisement

Answer

try the following:

Please find the db<>fiddle here.

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