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

边栏推荐
猜你喜欢
随机推荐
第一篇博客------自我介绍
Circular statements and functions of shell scripts
shell脚本之循环语句与函数
RHCE8学习指南 第4章 获取帮助
RHCE学习指南 第5章 vim编辑器
String Full Permutation Problem
认识交换机以及作用
FTP服务
正则表达式
Bladex - a well-designed microservice architecture
Leetcode 198:House Robber
Detailed explanation of dynamic compression and static compression of gzip
Usage instructions for MDK keil/arm printf
Binary installation kubernetes 1.23.2
DHCP service
Win10 下OneDrive 失效重装
Upgrade kubernetes 1.23.2 to 1.24.1
5、AsyncTool框架竟然有缺陷?
Arm cross compiler naming rules
DHCP principle and configuration
![[solution] the local Group Policy Editor (gpedit.msc) in Win 11 cannot be opened](/img/8c/705d5f03ca12eef740957c7c80a9f7.png)







