Description: Count how many times the action occurred in the night time considering the time from 6:00 p.m. to 6:00 p.m.
There is a better way to do such a select without having to use or to compare the periods?
select count(*) as contador,log_desc,'Noite' from log
where extract(hour from log_data_hora)>=0 and extract(hour fromlog_data_hora)<6
or extract(hour from log_data_hora)>18 and extract(hour from log_data_hora)<=23
group by log_desc,cor_cod
I'm using PostgreSQL.