我有一个如下所示的数据库:
我想找到一年中每个星期日的平均消费量
Τhe first record is "C11FA586148,*2013-07-01 01:00:00*,3"
The last record is "I13FA022711,*2014-07-01 19:00:00*,3
答案 0 :(得分:0)
以下查询将执行:
select customer,avg(consumption)
from test
where extract(dow from last_update_date)=7
group by customer
7 =星期日,1 =星期一,2 =星期二,等等。
另一种方式是
to_char(current_date, 'day')='sunday'