DB_SQL
xiaomifeng713
两只小蜜蜂啊飞到花丛中啊飞啊飞啊
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
1.1.1.2. coalesce 函数
coalesce 函数是用实际值来替换空值: SQL> select comm from emp; COMM--------- 300.00 500.00 1400.00 0.0014 rows selectedSQL> 使用coalesce :SQL> select coalesce(comm,123原创 2013-08-15 10:17:35 · 429 阅读 · 0 评论 -
SQL日常使用小方法:
一、去重复,没要求,只要求保单号相同记录的第一条记录,其它的不考虑select * from (select row_number () over (partition by policyno order by proposalno) rn,t.* from ods_cmain_all t where t.policyno='0120121101060060201原创 2014-03-20 10:31:32 · 445 阅读 · 0 评论 -
SQL;一列转多行的使用 --正则表达式的使用
需求:1policyno(保单号)列:0210130626000335001565/0211130626000332002226/0211130626000332002227/0211130626000332002227/0211130626000332002229/0211130626000332002210这是由多个保单号组成:需要整理成多行:policyno 021013原创 2014-03-20 10:20:49 · 932 阅读 · 0 评论 -
查找某个用户下的表,某个用户下某个表的列,及列类型
查找某个用户下的表,某个用户下某个表的列,及列类型 一、user_tables; select * from user_tables;二、user_tab_columsselect * from user_tab_columns where TABLE_NAME='ODS_PHEAD'; 作用:查找某个用户下面某个表下面某列是什么类型的,多长,等原创 2014-03-18 10:35:11 · 508 阅读 · 0 评论 -
SQLloader 导入文本字段有中特别符号的操作方法
导出生成落地文件的脚本:SELECT policyno 保单号, tsid 投诉id, aplname 投诉人姓名, aplmobile 投诉人手机, TO_CHAR (apldate, 'yyyy-mm-dd hh24:mi:ss') 投诉时间, apltype 投诉类型, ASCIISTR (replace原创 2013-12-26 10:49:40 · 2178 阅读 · 0 评论 -
标量子查询与内联视图哪个效率高?
现在有一个问题,标量子查询与内联视图哪个效率高?还没有解决,正在生成数据,节日过后准备叙述。原创 2013-09-27 11:35:17 · 945 阅读 · 0 评论 -
oracle 新功能model子句的简单使用
使用版本:>= 10G一、建立测试表-----------建立测试表 CREATE TABLE SALE_REPORT ( SALE_DATE DATE NOT NULL , SALE_ITEM VARCHAR(2) NOT NULL , SALE_MONEY DECIMAL(10,2) NOT NULL )二、测试原创 2013-09-16 10:34:31 · 845 阅读 · 0 评论 -
分析函数sum() over (order by ) 使用记录
环境:oracle 10.2.0.1.0用户:scott / tiger分析函数sum() over (order by ) 使用记录:SQL> select ename,sal,sum(sal) over(order by sal,empno) from emp order by 2;ENAME SAL SUM(SAL)OVER(ORDERBYSAL,原创 2013-09-03 16:34:19 · 5852 阅读 · 0 评论 -
另类的ORACLE分析函数over(partition by...)
oracle 分析函数使用的另类:over (partition by ......) 分析函数中使用case when ;例:SQL> with pctest as ( 2 SELECT 1 id ,'a1' name from dual 3 union 4 SELECT 1 id ,'a2' name from dual 5 union 6原创 2013-09-13 14:29:02 · 798 阅读 · 1 评论 -
一行转多行效果(一)
一行转多行效果显示:SQL> with test as ( select 'a',4,10 from dual union select 'b',2,8 from dual) select * from test;'A' 4 10--- ---------- ----------a 4原创 2013-09-05 11:46:48 · 477 阅读 · 0 评论 -
求某个用户下个有多少表,每表个中的多少行。
求某个用户下个有多少表,每表个中的多少行。以及求oracle 数据库认为表有多少行,实行表中有多少表。创建表 COUNTROWScreate table countrows as select owner, table_name, tablespace_name, num_rows, num_rows new_rows from dba_tables s原创 2013-08-16 17:37:16 · 588 阅读 · 0 评论 -
游标的个人使用理解
---------------静态显式游标 declare cursor A_cursor is select * from emp; ---直接声明游标begin for emp_rec in A_cursor loop dbms_output.put_line(emp_rec.ename || emp_rec.empno || emp_rec.sal原创 2013-08-16 16:54:23 · 818 阅读 · 0 评论 -
coalesce 函数的使用方法,
需求:表中有三列: mobile1,mobile2,mobile3 ,三列电话只,如果mobile1为空,使用mobile2,如果mobile2 也为空,使用mobile3,select coalesce(mobile1,replace(mobile2,' ',''),mobile3) mobile ,mobile1,mobile2,mobile3 from ods_customer_idv_原创 2014-03-21 11:41:54 · 1113 阅读 · 0 评论
分享