当前位置:网站首页>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 :

边栏推荐
猜你喜欢
随机推荐
echo -e用法
升级kubernetes 1.23.2到1.24.1
Expect interaction free
HCIA's first static routing experiment
5、AsyncTool框架竟然有缺陷?
多层数据包结构及TCP三次握手
Test knowledge preparation
3、AsyncTool框架原理源码解析
Unicast、Multicast、Broadcast
Dynamic display of digital tube stopwatch of single chip microcomputer
FTP服务
Services for NFS
String Full Permutation Problem
Squid agent service deployment
Traversal of binary tree
静态路由综合实验
OSPF comprehensive experiment
Shell编程规范与变量
FTP service
Rhce8 Study Guide Chapter 6 archiving and compression








