PLSQL中first_value和last_value取月初,月末

select sid,
       --日期
       sdate,
       --月初
       first_value(rValue) over(partition by sid, substr(sdate, 1, 6) order by sdate) as firstdayofmonth,
       --月末
       last_value(rValue) over(partition by sid, substr(sdate, 1, 6) order by sdate) as lastdayofmonth,
       --当前
       rValue,
  from DataTableName
原文地址:https://www.cnblogs.com/sshh/p/1277405.html