标签云
asm恢复 bbed bootstrap$ dul In Memory kcbzib_kcrsds_1 kccpb_sanity_check_2 kfed MySQL恢复 ORA-00312 ORA-00607 ORA-00704 ORA-01110 ORA-01555 ORA-01578 ORA-08103 ORA-600 2131 ORA-600 2662 ORA-600 2663 ORA-600 3020 ORA-600 4000 ORA-600 4137 ORA-600 4193 ORA-600 4194 ORA-600 16703 ORA-600 kcbzib_kcrsds_1 ORA-600 KCLCHKBLK_4 ORA-15042 ORA-15196 ORACLE 12C oracle dul ORACLE PATCH Oracle Recovery Tools oracle加密恢复 oracle勒索 oracle勒索恢复 oracle异常恢复 Oracle 恢复 ORACLE恢复 ORACLE数据库恢复 oracle 比特币 OSD-04016 YOUR FILES ARE ENCRYPTED 勒索恢复 比特币加密文章分类
- Others (2)
- 中间件 (2)
- WebLogic (2)
- 操作系统 (102)
- 数据库 (1,686)
- DB2 (22)
- MySQL (74)
- Oracle (1,548)
- Data Guard (52)
- EXADATA (8)
- GoldenGate (24)
- ORA-xxxxx (159)
- ORACLE 12C (72)
- ORACLE 18C (6)
- ORACLE 19C (15)
- ORACLE 21C (3)
- Oracle 23ai (7)
- Oracle ASM (68)
- Oracle Bug (8)
- Oracle RAC (53)
- Oracle 安全 (6)
- Oracle 开发 (28)
- Oracle 监听 (28)
- Oracle备份恢复 (566)
- Oracle安装升级 (92)
- Oracle性能优化 (62)
- 专题索引 (5)
- 勒索恢复 (80)
- PostgreSQL (18)
- PostgreSQL恢复 (6)
- SQL Server (27)
- SQL Server恢复 (8)
- TimesTen (7)
- 达梦数据库 (2)
- 生活娱乐 (2)
- 至理名言 (11)
- 虚拟化 (2)
- VMware (2)
- 软件开发 (37)
- Asp.Net (9)
- JavaScript (12)
- PHP (2)
- 小工具 (20)
-
最近发表
- .hmallox加密mariadb/mysql数据库恢复
- 2025年首个故障恢复—ORA-600 kcbzib_kcrsds_1
- 第一例Oracle 21c恢复咨询
- ORA-15411: Failure groups in disk group DATA have different number of disks.
- 断电引起的ORA-08102: 未找到索引关键字, 对象号 39故障处理
- ORA-00227: corrupt block detected in control file
- 手工删除19c rac
- 解决oracle数据文件路径有回车故障
- .wstop扩展名勒索数据库恢复
- Oracle Recovery Tools工具一键解决ORA-00376 ORA-01110故障(文件offline)
- OGG-02771 Input trail file format RELEASE 19.1 is different from previous trail file form at RELEASE 11.2.
- OGG-02246 Source redo compatibility level 19.0.0 requires trail FORMAT 12.2 or higher
- GoldenGate 19安装和打patch
- dd破坏asm磁盘头恢复
- 删除asmlib磁盘导致磁盘组故障恢复
- Kylin Linux 安装19c
- ORA-600 krse_arc_complete.4
- Oracle 19c 202410补丁(RUs+OJVM)
- ntfs MFT损坏(ntfs文件系统故障)导致oracle异常恢复
- .mkp扩展名oracle数据文件加密恢复
分类目录归档:Oracle 开发
lag() lead()函数使用
1、语法
LAG (value_expression [,offset] [,default]) OVER ([query_partition_clause] order_by_clause)
LEAD (value_expression [,offset] [,default]) OVER ([query_partition_clause] order_by_clause)
2、说明
1)lag 和lead 可以 获取结果集中,按一定排序所排列的当前行的上下相邻若干offset 的某个行的某个列(不用结果集的自关联)
2)lag 和lead 有三个参数,第一个参数是列名,第二个参数是偏移的offset,第三个参数是超出记录窗口时的默认值
3)lag ,lead 分别是向前,向后
3、准备试验环境
CREATE TABLE t(t_NAME VARCHAR2(10),t_order NUMBER); INSERT INTO t VALUES('aaaa',1); INSERT INTO t VALUES('bbbb',2); INSERT INTO t VALUES('cccc',3); INSERT INTO t VALUES('dddd',6); INSERT INTO t VALUES('eeee',4); INSERT INTO t VALUES('ffff',5); SELECT * FROM t; T_NAME T_ORDER ---------- ---------- aaaa 1 bbbb 2 cccc 3 dddd 6 eeee 4 ffff 5 6 rows selected
4、测试
SELECT T_ORDER, LAG(T_NAME, 1,'lag_fei') OVER(ORDER BY T_ORDER) "LAG", T_NAME, LEAD(T_NAME, 1,'lead_fei') OVER(ORDER BY T_ORDER)"LEAD" FROM T ORDER BY T_ORDER; T_ORDER LAG T_NAME LEAD ---------- ---------- ---------- ---------- 1 lag_fei aaaa bbbb 2 aaaa bbbb cccc 3 bbbb cccc eeee 4 cccc eeee ffff 5 eeee ffff dddd 6 ffff dddd lead_fei 6 rows selected
发表在 Oracle 开发
评论关闭
grouping_id()使用
1、创建表
desc test_rollup; Name Type Nullable Default Comments ----------- ------------ -------- ------- -------- TYPE_NAME VARCHAR2(10) Y TYPE_VALUE NUMBER Y TYPE_NAME2 VARCHAR2(10) Y TYPE_VALUE2 NUMBER Y
2、插入数据
select * from test_rollup; TYPE_NAME TYPE_VALUE TYPE_NAME2 TYPE_VALUE2 ---------- ---------- ---------- ----------- a 123 t1 120 a 423 t2 200 a 523 t1 555 b 223 x1 504 b 283 x2 484 c 103 y1 333 c 843 y2 984 c 899 y2 151 c 100 y2 150 d 204 s1 606 10 rows selected
3、使用grouping_id查询结果
select type_name, type_name2, decode(grouping_id(type_name), 0, type_name, '总计')g_type, decode(grouping_id(type_name2), 0, type_name2, decode(grouping_id(type_name),0,'小计','总计'))g2_type, grouping_id(type_name, type_name2)gg_type, sum(type_value), sum(type_value2) from test_rollup group by rollup(type_name, type_name2); TYPE_NAME TYPE_NAME2 G_TYPE G2_TYPE GG_TYPE SUM(TYPE_VALUE) SUM(TYPE_VALUE2) ---------- ---------- ---------- ---------- ---------- --------------- ---------------- a t1 a t1 0 646 675 a t2 a t2 0 423 200 a a 小计 1 1069 875 b x1 b x1 0 223 504 b x2 b x2 0 283 484 b b 小计 1 506 988 c y1 c y1 0 103 333 c y2 c y2 0 1842 1285 c c 小计 1 1945 1618 d s1 d s1 0 204 606 d d 小计 1 204 606 总计 总计 3 3724 4087 12 rows selected
发表在 Oracle 开发
评论关闭