How to group data according to day and night in InfluxDB Query?

Hi all!, I am working on an energy monitoring application and storing all-time series data into InfluxDB. Now I have a use-case where I have to get average power uses according to Day and Night. Ex total consumption is 150W (80W during Night and 70W during Day). So how can I query data according to day and night?