自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Oracle數(shù)據(jù)庫分析函數(shù)應(yīng)用實例之查找狀態(tài)全為1的ID

數(shù)據(jù)庫 Oracle
本文我們主要介紹了一個Oracle數(shù)據(jù)庫分析函數(shù)的應(yīng)用實例,即查找數(shù)據(jù)庫中狀態(tài)全為1的ID的實現(xiàn)過程,希望本次的介紹能夠?qū)δ兴斋@!

Oracle數(shù)據(jù)庫分析函數(shù)應(yīng)用實例之查找狀態(tài)全為1的ID是本文我們主要要介紹的內(nèi)容,通過本文的例子讓我們來一起了解一下Oracle數(shù)據(jù)庫分析函數(shù)的使用吧,希望能夠?qū)δ兴鶐椭?/p>

實例如下:

1、表結(jié)構(gòu)和測試數(shù)據(jù)插入

建表:

 

 

  1. create table TAB_FXHS    
  2. (    
  3. id VARCHAR2(32),    
  4. zt VARCHAR2(2)    
  5. );   

 

-- Add comments to the table    

 

  1. comment on table TAB_FXHS    
  2. is '用于統(tǒng)計狀態(tài)值全為正常的id值';   

 

 

-- Add comments to the columns    

 

  1. comment on column TAB_FXHS.id    
  2. is '主鍵ID';    
  3. comment on column TAB_FXHS.zt    
  4. is '狀態(tài)';   

 

插入測試數(shù)據(jù):

 

  1. prompt Importing table TAB_FXHS...    
  2. set feedback off    
  3. set define off    
  4. insert into TAB_FXHS (ID, ZT)values ('10125', '0');    
  5. insert into TAB_FXHS (ID, ZT)values ('10161', '0');    
  6. insert into TAB_FXHS (ID, ZT)values ('10141', '0');    
  7. insert into TAB_FXHS (ID, ZT)values ('10126', '1');    
  8. insert into TAB_FXHS (ID, ZT)values ('10102', '0');    
  9. insert into TAB_FXHS (ID, ZT)values ('10103', '0');    
  10. insert into TAB_FXHS (ID, ZT)values ('10121', '0');    
  11. insert into TAB_FXHS (ID, ZT)values ('10121', '1');    
  12. insert into TAB_FXHS (ID, ZT)values ('10121', '0');    
  13. insert into TAB_FXHS (ID, ZT)values ('10121', '3');    
  14. prompt Done.   

 

2、 功能需求說明

在表TAB_FXHS中,ID是關(guān)鍵字段,ZT是狀態(tài)。

ID中可能會有重復(fù)的值,現(xiàn)在要求找出ZT全為1的所有ID值。

3、功能實現(xiàn)的SQL語句 

 

  1. WITH ZT_PARTITION_BY_ID AS    
  2. (SELECT ID, ZT, COUNT(ZT) OVER(PARTITION BY ID ORDER BY ID) ID_ZT    
  3. FROM TAB_FXHS    
  4. GROUP BY ID, ZT)    
  5. SELECT *    
  6. FROM ZT_PARTITION_BY_ID    
  7. WHERE ID_ZT = 1    
  8. AND ZT = 1;   

 

以上就是Oracle數(shù)據(jù)庫中分析函數(shù)的應(yīng)用實例之實現(xiàn)查找狀態(tài)全為1的ID的全部過程,本文就介紹到這里了,希望本次的介紹能夠?qū)δ兴斋@!

【編輯推薦】

  1. Oracle 10g內(nèi)存結(jié)構(gòu)之系統(tǒng)全局區(qū)簡介
  2. Oracle數(shù)據(jù)庫中行轉(zhuǎn)列以及Join用法總結(jié)
  3. Oracle regexp_like的相關(guān)知識及使用示例
  4. Oracle 10g內(nèi)存結(jié)構(gòu)之共享池的相關(guān)知識及使用簡介
  5. Oracle 10g內(nèi)存結(jié)構(gòu)之排序區(qū)和Java池的相關(guān)知識簡介
責(zé)任編輯:趙鵬 來源: CSDN博客
相關(guān)推薦

2010-04-02 16:03:20

Oracle數(shù)據(jù)庫

2010-04-13 10:55:35

Oracle數(shù)據(jù)庫

2011-05-19 13:25:14

Oracle數(shù)據(jù)庫

2011-08-18 10:36:24

SQL ServerISNULL函數(shù)

2011-03-29 10:47:49

ORACLE數(shù)據(jù)庫

2010-04-14 15:45:49

Oracle 數(shù)據(jù)庫

2010-04-06 11:30:09

Oracle 數(shù)據(jù)庫

2011-08-16 18:55:10

Oracle數(shù)據(jù)庫構(gòu)造過程

2011-05-26 15:27:08

Oracle數(shù)據(jù)庫

2011-08-11 16:55:34

Oracle數(shù)據(jù)庫AWR

2010-04-23 09:32:39

Oracle數(shù)據(jù)庫實例

2011-08-22 14:50:20

2009-02-03 08:58:13

SQL*Net配置網(wǎng)絡(luò)應(yīng)用

2011-08-09 18:15:24

Oracle 10g查找數(shù)據(jù)

2009-11-20 13:29:59

Oracle數(shù)據(jù)庫恢復(fù)

2025-04-08 06:00:00

2010-04-26 13:23:49

Oracle數(shù)據(jù)庫

2010-04-14 17:57:52

Oracle數(shù)據(jù)庫

2011-07-29 16:21:21

Oracle數(shù)據(jù)庫回滾段

2011-03-11 16:42:51

Oracle數(shù)據(jù)庫視圖
點贊
收藏

51CTO技術(shù)棧公眾號