pgsql查询近一日,近一月,近一年的数据

select count(*) from "表名" 
WHERE 字段 >= (select now() - interval '1 month') and 字段 <=now();
        
select count(*)from "表名" 
WHERE 字段 >= (select now() - interval '1 year') and 字段 <=now() ;

select count(*)from "表名" WHERE 字段 >= (select now() - interval '1 day') and 字段 <=now() ;

你可能感兴趣的:(后端开发,java,sql)