当前位置:网站首页>Oracle gets the last and first data (gets the first and last data by time)
Oracle gets the last and first data (gets the first and last data by time)
2022-07-19 02:54:00 【The sound of the waves is still loud】
Let 's say we have the following scenario :
Electric meter , Everyone knows that the reading of electricity meter is not the real power consumption , Real power consumption = This reading - Last reading
The meter design is as follows :

SQL The statement is as follows , Use Oracle Of FIRST_VALUE() and LAST_VALUE() Function implementation :
SELECT
DISTINCT
LAST_VALUE (E_VALUE) OVER (PARTITION BY E_CODE ORDER BY E_DATE ROWS BETWEEN unbounded preceding AND unbounded following) AS LAST_TIME_VALUE,
FIRST_VALUE (E_VALUE) OVER (PARTITION BY E_CODE ORDER BY E_DATE ROWS BETWEEN unbounded preceding AND unbounded following) AS FIRST_TIME_VALUE
FROM
TABLE_TESTresult :

边栏推荐
猜你喜欢
随机推荐
认识交换机以及作用
Configure VLAN and use OSPF protocol for layer 3 switches
Shell script for, while loop statements, price guessing games
从MySQL架构看一条SQL语句是如何执行的?
TCP的三次握手与四次断开
NAT综合实验
Expect interaction free
三层交换机配置VLAN和使用OSPF协议
HCIA static comprehensive experiment
GFS分布式文件系统
RHCE学习指南 第5章 vim编辑器
Rsync remote synchronization (incremental backup)
Image quality evaluation indicators: SNR, PSNR, MSE and SSIM
了解网络命名空间
Conditional statement of shell script
Rhce8 Study Guide Chapter 7 service management
RIP综合实验
Echo -e usage
【NoSQL】NoSQL之redis配置与优化(简单操作)
High quality subroutine









