时间:2021-07-01 10:21:17 帮助过:3人阅读
oracle: 数值随机的函数是 dbms_random.value(最大值,最小值) 用法是select dbms_random(3,0) from dual;
oracle: 获取前100条 的函数是 rownumber <=100 用法是select * from dual where rownumber<=100;
oracle: cast((nvl(sum(case b.hgxs when b.jcxs then 1 end),0)/nvl(count(a.id),0))*100 as decimal(18,2)) 类型转换
按小时分组,每个小时里面有好些笔数据,每个小时内只取一笔数据
partition by 是分组,每小时取一笔数据所以就按小时分组,同时,按照id 也是每个id里面取一条数据,(为的是id不丢失)
oracle: row_number() over(partition by to_char(a.sjsj,‘yyyy-MM-dd hh24‘),c.id order by to_char(a.sjsj,‘yyyy-MM-dd hh24‘) desc) newIndex
where newIndex<=1 定义,每个组里取1 到0 条数据,
用法是:
select * from (
select row_number() over(partition by to_char(a.sjsj,‘yyyy-MM-dd hh24‘),c.id order by to_char(a.sjsj,‘yyyy-MM-dd hh24‘) desc) newIndex ) bb
where bb.newIndex <=1;
oracle:获取某一个月的天数:to_char(last_day(to_date(e.ny,‘yyyy-mm‘)),‘dd‘)
oracle 小知识
标签: