WHERE TO_NUMBER(SUBSTR()) 我的是可以的

HUNTER@devjob>CREATE TABLE T_PART (ID NUMBER, CREATE_DATE DATE)
  2  PARTITION BY RANGE (CREATE_DATE)
  3  (
  4  PARTITION P2004 VALUES LESS THAN (TO_DATE('2005-1-1', 'YYYY-MM-DD')),
  5  PARTITION P2005 VALUES LESS THAN (TO_DATE('2006-1-1', 'YYYY-MM-DD')),
  6  PARTITION P2006 VALUES LESS THAN (TO_DATE('2007-1-1', 'YYYY-MM-DD')),
  7  PARTITION P2007 VALUES LESS THAN (TO_DATE('2008-1-1', 'YYYY-MM-DD'))
  8  );

Table created.


HUNTER@devjob>select table_name,partition_name from user_tab_partitions;

TABLE_NAME                     PARTITION_NAME
------------------------------ ------------------------------
T_PART                         P2004
T_PART                         P2005
T_PART                         P2006
T_PART                         P2007


HUNTER@devjob>SELECT TO_NUMBER(SUBSTR(PARTITION_NAME, 2)) FROM USER_TAB_PARTITIONS;

TO_NUMBER(SUBSTR(PARTITION_NAME,2))
-----------------------------------
                               2004
                               2005
                               2006
                               2007

HUNTER@devjob>SELECT TABLE_NAME, PARTITION_NAME FROM USER_TAB_PARTITIONS  WHERE TO_NUMBER(SUBSTR(PARTITION_NAME, 2)) < 2006;

TABLE_NAME                     PARTITION_NAME
------------------------------ ------------------------------
T_PART                         P2005
T_PART                         P2004

HUNTER@devjob>SELECT * FROM
  2  (
  3  SELECT TABLE_NAME, PARTITION_NAME, TO_NUMBER(SUBSTR(PARTITION_NAME, 2)) PART
  4  FROM USER_TAB_PARTITIONS
  5  )
  6  WHERE PART < 2006;

TABLE_NAME                     PARTITION_NAME                       PART
------------------------------ ------------------------------ ----------
T_PART                         P2005                                2005
T_PART                         P2004                                2004

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7364032/viewspace-368774/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/7364032/viewspace-368774/

解读下这段sqlselect region_code,count(*) from ( select substr(region_code,0,6) region_code,receive_number from tysl.accept_business_index where receive_time between to_date('2023/5/1','yyyy/mm/dd') and to_date('2023/6/1','yyyy/mm/dd') and state !='90' union all select substr(region_code,0,6) region_code,receive_number from tysl_gy.accept_business_index where receive_time between to_date('2023/5/1','yyyy/mm/dd') and to_date('2023/6/1','yyyy/mm/dd') and state !='90' union all select substr(region_code,0,6) region_code,receive_number from tysl_zy.accept_business_index where receive_time between to_date('2023/5/1','yyyy/mm/dd') and to_date('2023/6/1','yyyy/mm/dd') and state !='90' union all select substr(region_code,0,6) region_code,receive_number from tysl_lps.accept_business_index where receive_time between to_date('2023/5/1','yyyy/mm/dd') and to_date('2023/6/1','yyyy/mm/dd') and state !='90' union all select substr(region_code,0,6) region_code,receive_number from tysl_ga.accept_business_index where receive_time between to_date('2023/5/1','yyyy/mm/dd') and to_date('2023/6/1','yyyy/mm/dd') and state !='90' union all select substr(region_code,0,6) region_code,receive_number from tysl_as.accept_business_index where receive_time between to_date('2023/5/1','yyyy/mm/dd') and to_date('2023/6/1','yyyy/mm/dd') and state !='90' union all select substr(region_code,0,6) region_code,receive_number from tysl_bjs.accept_business_index where receive_time between to_date('2023/5/1','yyyy/mm/dd') and to_date('2023/6/1','yyyy/mm/dd') and state !='90' union all select substr(region_code,0,6) region_code,receive_number from tysl_trs.accept_business_index where receive_time between to_date('2023/5/1','yyyy/mm/dd') and to_date('2023/6/1','yyyy/mm/dd') and state !='90' union all select substr(region_code,0,6) region_code,receive_number from tysl_qn.accept_business_index where receive_time between to_date('2023/5/1','yyyy/mm/dd') and to_date('2023/6/1','yyyy/mm/dd') and state !='90' union all select substr(region_code,0,6) region_code,receive_number from tysl_qxn.accept_business_index where receive_time between to_date('2023/5/1','yyyy/mm/dd') and to_date('2023/6/1','yyyy/mm/dd') and state !='90' union all select substr(region_code,0,6) region_code,receive_number from tysl_qdn.accept_business_index where receive_time between to_date('2023/5/1','yyyy/mm/dd') and to_date('2023/6/1','yyyy/mm/dd') and state !='90' )group by region_code order by region_code
06-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值