??xml version="1.0" encoding="utf-8" standalone="yes"?>国产视频福利在线,蜜桃tv一区二区三区,久久一区二区视频http://www.aygfsteel.com/piliskys/archive/2006/09/20/70831.html霚w?/dc:creator>霚w?/author>Wed, 20 Sep 2006 08:20:00 GMThttp://www.aygfsteel.com/piliskys/archive/2006/09/20/70831.htmlhttp://www.aygfsteel.com/piliskys/comments/70831.htmlhttp://www.aygfsteel.com/piliskys/archive/2006/09/20/70831.html#Feedback0http://www.aygfsteel.com/piliskys/comments/commentRss/70831.htmlhttp://www.aygfsteel.com/piliskys/services/trackbacks/70831.htmlSELECT a.TAXPAYERID TAXPAYERID$0, a.INDEPOTYEAR INDEPOTYEAR$2
SUM(a.TAXFINAL) SUMTAXFINAL$1 
FROM F_LVY_LEVYINPUTYEARHISTORYDATA a 
WHERE substr ( a.TAXPAYERID ,1 , 1 ) 'T' and a.indepotyear='2006' GROUP BY a.TAXPAYERID, a.INDEPOTYEAR having SUM(a.TAXFINAL) >=1000000 W一ơ运行?357条记录,然后接着q行变?359Q此为正数Q,到网上找了下Q没有找到原因, 最后把substr ( a.TAXPAYERID ,1 , 1 ) 'T' 改ؓ a.TAXPAYERID not like 'T%'没有问题Q把上面sql改ؓ
SELECT a.TAXPAYERID TAXPAYERID$0, a.INDEPOTYEAR INDEPOTYEAR$2SUM(a.TAXFINAL) SUMTAXFINAL$1 FROM F_LVY_LEVYINPUTYEARHISTORYDATA a WHERE a.indepotyear='2006' GROUP BY a.TAXPAYERID, a.INDEPOTYEAR having SUM(a.TAXFINAL) >=1000000 and substr ( a.TAXPAYERID ,1 , 1 ) 'T' 
也没有问题, 而所有记录中substr ( a.TAXPAYERID ,1 , 1 )只有三种0,1,T, a.TAXPAYERID没有为空的,不清楚ؓ何如此?Q?

]]>
SQL角本-建物化视?/title><link>http://www.aygfsteel.com/piliskys/archive/2006/09/07/68322.html</link><dc:creator>霚w?/dc:creator><author>霚w?/author><pubDate>Thu, 07 Sep 2006 09:13:00 GMT</pubDate><guid>http://www.aygfsteel.com/piliskys/archive/2006/09/07/68322.html</guid><wfw:comment>http://www.aygfsteel.com/piliskys/comments/68322.html</wfw:comment><comments>http://www.aygfsteel.com/piliskys/archive/2006/09/07/68322.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/piliskys/comments/commentRss/68322.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/piliskys/services/trackbacks/68322.html</trackback:ping><description><![CDATA[ <p>目的Q对某表创徏物化视图Ӟ不要求它所有字D,因此必须列出要的字段Q一个个字段COPY也比较麻?因此写一角本<br /></p> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> <span style="COLOR: #0000ff">select</span> <span style="COLOR: #000000"> <br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span> <span style="COLOR: #ff0000">'</span> <span style="COLOR: #ff0000">create  materialized view </span> <span style="COLOR: #ff0000">'</span> <span style="COLOR: #808080">||</span> <span style="COLOR: #ff00ff">max</span> <span style="COLOR: #000000">(a.table_name)</span> <span style="COLOR: #808080">||</span> <span style="COLOR: #000000">chr(</span> <span style="FONT-WEIGHT: bold; COLOR: #800000">10</span> <span style="COLOR: #000000">)</span> <span style="COLOR: #808080">||</span> <span style="COLOR: #000000"> <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />   </span> <span style="COLOR: #ff0000">'</span> <span style="COLOR: #ff0000">tablespace staging refresh fast  as select</span> <span style="COLOR: #ff0000">'</span> <span style="COLOR: #808080">||</span> <span style="COLOR: #000000">chr(</span> <span style="FONT-WEIGHT: bold; COLOR: #800000">10</span> <span style="COLOR: #000000">)</span> <span style="COLOR: #808080">||</span> <span style="COLOR: #000000"> <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> substr(</span> <span style="COLOR: #ff00ff">max</span> <span style="COLOR: #000000">(sys_connect_by_path(a.column_name</span> <span style="COLOR: #808080">||</span> <span style="COLOR: #000000">chr(</span> <span style="FONT-WEIGHT: bold; COLOR: #800000">10</span> <span style="COLOR: #000000">),</span> <span style="COLOR: #ff0000">'</span> <span style="COLOR: #ff0000">,</span> <span style="COLOR: #ff0000">'</span> <span style="COLOR: #000000">)),</span> <span style="FONT-WEIGHT: bold; COLOR: #800000">2</span> <span style="COLOR: #000000">)</span> <span style="COLOR: #808080">||</span> <span style="COLOR: #000000"> <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #ff0000">'</span> <span style="COLOR: #ff0000">from </span> <span style="COLOR: #ff0000">'</span> <span style="COLOR: #808080">||</span> <span style="COLOR: #ff00ff">max</span> <span style="COLOR: #000000">(a.table_name)</span> <span style="COLOR: #808080">||</span> <span style="COLOR: #ff0000">'</span> <span style="COLOR: #ff0000">@zhengguan t;</span> <span style="COLOR: #ff0000">'</span> <span style="COLOR: #008080">--</span> <span style="COLOR: #008080">q里是DBLINK</span> <span style="COLOR: #008080"> <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #000000"> <br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />  </span> <span style="COLOR: #0000ff">from</span> <span style="COLOR: #000000"> <br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />( </span> <span style="COLOR: #0000ff">select</span> <span style="COLOR: #000000"> row_number() </span> <span style="COLOR: #0000ff">over</span> <span style="COLOR: #000000">( PARTITION </span> <span style="COLOR: #0000ff">BY</span> <span style="COLOR: #000000"> g.table_name  </span> <span style="COLOR: #0000ff">order</span> <span style="COLOR: #000000"> </span> <span style="COLOR: #0000ff">by</span> <span style="COLOR: #000000"> g.column_id  )  rn <br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />    ,g.table_name,g.column_name  </span> <span style="COLOR: #0000ff">from</span> <span style="COLOR: #000000"> <br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />         user_tab_cols  g<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />          </span> <span style="COLOR: #0000ff">where</span> <span style="COLOR: #000000"> g.table_name </span> <span style="COLOR: #808080">=</span> <span style="COLOR: #ff0000">'</span> <span style="COLOR: #ff0000">TB_LVY_INCREASEDECREASEDATA</span> <span style="COLOR: #ff0000">'</span> <span style="COLOR: #000000"> </span> <span style="COLOR: #008080">--</span> <span style="COLOR: #008080">q里是要建的表名</span> <span style="COLOR: #008080"> <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #000000">          ) a<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />          <br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />           start </span> <span style="COLOR: #0000ff">with</span> <span style="COLOR: #000000"> rn</span> <span style="COLOR: #808080">=</span> <span style="FONT-WEIGHT: bold; COLOR: #800000">1</span> <span style="COLOR: #000000"> <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />          connect </span> <span style="COLOR: #0000ff">by</span> <span style="COLOR: #000000">  rn </span> <span style="COLOR: #808080">=</span> <span style="COLOR: #000000">  prior rn </span> <span style="COLOR: #808080">+</span> <span style="FONT-WEIGHT: bold; COLOR: #800000">1</span> </div>q用Q对于一些存储过E中对表的insertӞq样也许可减些工作量,反正灉|q用吧,一个角本也讔R过自己的变化,在工作中可以启到一定的作用?img src ="http://www.aygfsteel.com/piliskys/aggbug/68322.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/piliskys/" target="_blank">霚w?/a> 2006-09-07 17:13 <a href="http://www.aygfsteel.com/piliskys/archive/2006/09/07/68322.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>oracle 中的nulllhttp://www.aygfsteel.com/piliskys/archive/2005/12/16/24120.html霚w?/dc:creator>霚w?/author>Fri, 16 Dec 2005 01:26:00 GMThttp://www.aygfsteel.com/piliskys/archive/2005/12/16/24120.htmlhttp://www.aygfsteel.com/piliskys/comments/24120.htmlhttp://www.aygfsteel.com/piliskys/archive/2005/12/16/24120.html#Feedback0http://www.aygfsteel.com/piliskys/comments/commentRss/24120.htmlhttp://www.aygfsteel.com/piliskys/services/trackbacks/24120.html昨日在一存储q程中测试时发现在where 条g中用了一A=null,l果是不q回Ml果Q以前Lwhere 中写is null,is not null,不能区别q两者的分别Q然后上|找了些资料QA=null时无论A是nullq是其它Q都q回是false,可以说有点像null是false跟其它的与操作,l果也就是都是false,而我们在set的时候置为空是用=null的,
因此我们在考虑一字段作条件时要考虑它是否可能ؓI的Q有I时最好结?nvl函数使用Q以免把要的记录l漏?......



]]>
oracle中的函数http://www.aygfsteel.com/piliskys/archive/2005/12/02/22211.html霚w?/dc:creator>霚w?/author>Fri, 02 Dec 2005 02:57:00 GMThttp://www.aygfsteel.com/piliskys/archive/2005/12/02/22211.htmlhttp://www.aygfsteel.com/piliskys/comments/22211.htmlhttp://www.aygfsteel.com/piliskys/archive/2005/12/02/22211.html#Feedback0http://www.aygfsteel.com/piliskys/comments/commentRss/22211.htmlhttp://www.aygfsteel.com/piliskys/services/trackbacks/22211.htmlOracle已经内徏了许多函敎ͼ不同的函数有不同的作用和用法Q有的函数只能作用在一个记录行上,有的能够作用在多个记录行上,不同的函数可能处理不同的数据cd。常见的有两c,单行函数和分l函??/FONT>

单行函数Q?/FONT>

单行函数

分类 函数 功能 CZ
字符函数 LPAD(<c1>,<i>[,<c2>]) 在字W串c1的左Ҏ加字W串c2直到c1字符串的长度{于i?/SPAN>

SELECT  LPAD(‘Hello!?8,?? leftpad,RPAD(‘Hello!?8,?? rightpad

FROM DUAL;

 

RPAD(<c1>,<i>[,<c2>]) 在字W串c1的右Ҏ加字W串c2直到c1字符串的长度{于i?/SPAN>
LOWER(<c1>) 把字W串c1转换为小?/SPAN> SELECT LOWER(ename)  one,UPPER(ename) two, INITCAP(ename) FROM EMP;
UPPER(<c1>) 把字W串c1转换为大?/SPAN>
INITCAP(<c1>) ?/SPAN>c1字符串的每一个单词的W一个字母{换成大写字母
LENGTH(<c1>) q回字符?/SPAN>c1的长?/SPAN> SELECT LENGTH(‘How are you? FROM DUAL;
SUBSTR(<c1>,<i>[,<j>]) q回字符?/SPAN>c1中从W?/SPAN>i个位|开始的j个字W(向右Q。如果省?/SPAN>jQ则q回c1中从W?/SPAN>i个位|开始的所有字W。如?/SPAN>jQ则q回字符?/SPAN>c1中从W?/SPAN>i个位|开始的j个字W(向左Q?/SPAN> SELECT SUBSTR(‘Hello,World?1,5) FROM DUAL;
INSTR(<c1>,<c2>[,<i>[,<j>]]) ?/SPAN>c1中从位置i开始查?/SPAN>c2?/SPAN>c1中出W?/SPAN>jơ的位置Q?/SPAN>i可以(此时Q从c1的尾部开?/SPAN>)?/SPAN>

SELECT INSTR(‘Mississippi?’i?3,3) FROM DUAL; q回l果11?/SPAN>

SELECT INSTR(‘Mississippi?’i?-2,3) FROM DUAL; q回l果2?/SPAN>

 

LTRIM(<c1>,<c2>) ?/SPAN>c1前面开始去掉出现在c2的中M前导字符集?/SPAN> SELECT LTRIM(‘Mississippi?’Mis? FROM DUAL; q回l果’ppi’?BR>
SELECT RTRIM(‘Mississippi?’ip? FROM DUAL; q回l果’Mississ’?BR> 
RTRIM(<c1>,<c2>) ?/SPAN>c1后面开始去掉出现在c2的中M前导字符集?/SPAN>
数学函数 ABS(<n>) q回n的绝对?/SPAN> SELECT ABC(-2),ABS(2) FROM DUAL;
ROUND(<n1>,<n2>) ?/SPAN>n1的小数点后保?/SPAN>n2位(四舍五入Qƈq回。如?/SPAN>n2于Ӟn1舍入到小数点左边?/SPAN>

SELECT ROUND(12345.678,-2),

ROUND(12345.678,2)

 FROM  DUAL;

分别q回l果Q?/SPAN>12300Q?/SPAN>12345.68?/SPAN>

 

CEIL(<n>) ?/SPAN>n 向上取整Qƈq回?/SPAN>

SELECT CEIL(5.1),CEIL(-21.4) FROM  DUAL;

分别q回Q?/SPAN>6, -21?/SPAN>

 

FLOOR(<n>) ?/SPAN>n 向下取整Qƈq回?/SPAN>

SELECT FLOOR(5.1),FLOOR(-21.4) FROM  DUAL;

分别q回Q?/SPAN>5, -22?/SPAN>

 

MOD(<n1>,<n2>) q回n1?/SPAN>n2后的余数?/SPAN>

SELECT MOD(14,5),MOD(8,25),MOD(-64,7) FROM DUAL;

分别q回l果Q?/SPAN>4Q?/SPAN>0.5Q?/SPAN>-1?/SPAN>

 

SIGN(<n>)

W号函数Q?/SPAN>n>0Q返?/SPAN>1?/SPAN>

n<0Q返?/SPAN>-1?/SPAN>

n=0Q返?/SPAN>0?/SPAN>

 

SELECT SIGN(-2.3),SIGN(2.3),SIGN(0) FROM DUAL;
SQRT(<n>) q回n的^Ҏ SELECT SQRT(9) FROM DUAL;
TRUNC(<n1>,<n2>) 功能cMROUND函数。但不做四舍五入?/SPAN>

SELECT TRUNC(123.456,2),TRUNC(123.456,-1) FROM DUAL;

分别q回l果Q?/SPAN>123.45?/SPAN>120?/SPAN>

 

VSIZE(n) q回数字n的存储字?/SPAN> SELECT VSIZE(123) FROM DUAL;
日期函数(日期可以q行术q算) SYSDATE q回相同日期 SELECT SYSDATE FROM DUAL;
ADD_MONTHS(<d>,<i>) q回日期d 加上i个月后的新日?/SPAN>(i正可?/SPAN>)?/SPAN>

SELECT SYSDATE, ADD_MONTHS(SYSDATE,2),

ADD_MONTHS(SYSDATE,-2)

FROM DUAL;

 

LAST_DAY(<d>) q回日期d所在的月的最后一天?/SPAN> SELECT SYSDATE,LAST_DAY(SYSDATE) FROM DUAL
MONTHS_BETWEEN(<d1>,<d2>) q回日期d1?/SPAN>d2大多月数?/SPAN> SELECT MONTHS_BETWEEN(?9-Dec-1999??9-Mar-2000?FROM DUAL;
NEW_TIME(<d>,<tz1>,<tz2>) 时?/SPAN>tz1的时?/SPAN>dQ{换ؓ时区tz2里的旉?/SPAN> SELECT SYSDATE,NEW_TIME(SYSDATE,’CDT?’PDT? FROM DUAL;
NEXT_DAY(<d>,<dow>) q回日期d后的W一?/SPAN>dow?/SPAN>(dowQ?/SPAN>day of week) SELECT NEXT_DAY(SYSDATE,’Monday? FROM DUAL;
常用转换函数 TO_CHAR(<x>[,<fmt>[,<nlsparm>]]) ?/SPAN>x转换成字W串。(参数含义LORACLE的联机帮助) SELECT TO_CHAR(SYSDATE,’YYYY-MM-DD? FROM DUAL;
TO_NUMBER(<c>[,<fmt>[,<nlsparm>]]) 字W串c转换成数字。(参数含义LORACLE的联机帮助) SELECT TO_NUMBER(?23? FROM DUAL;

TO_DATE(<c>[,<fmt>[,<nlsparm>]])

(常见的日期格式请查联机帮助?/SPAN>)

字W串c转换成日期?/SPAN> SELECT TO_DATE(?9-Mar-99?’DD-Mon-YYYY? FROM DUAL;
两个重要函数

DECODE(<x>,<m1>,<r1>[,<m2>,

<r2?gt;][,<d>])

(DECODE函数功能非常强大Q请仔细玩味?/SPAN>)

 

一个功能非常强大的函数Q它使得SQL非常高效。它的功能类g一pd?/SPAN>if…then…else语句?/SPAN>

SELECT sid,serial#,username,

DECODE(command

,0,’None?/FONT>

,2,’Insert?/FONT>

,3,’Select?/FONT>

,6,’Update?/FONT>

,7,’Delete?/FONT>

,8,’Drop

,’Other? cmd

FROM V$SESSION WHERE type<>’BACKGROUND?

 

NVL(x1,x2)

注意ORACLE中的NULL|注意该函C?/SPAN>

 

如果x1为空q回x2Q否则返?/SPAN>x1?/SPAN> SELECT NVL(ename,?/SPAN>无姓?/SPAN>?  FROM  EMP;

分组函数

  AVG([{DISTINCT|ALL}]<n>) 求返回行的指定列的^均?/FONT>

SELECT AVG(sal),AVG(ALL sal),AVG(DISTINCT sal)

FROM SCOTT.EMP;

 

COUNT({*|[DISTINCT|ALL]}<x>) l计q回的行?/FONT>

SELECT COUNT (*), COUNT(DISTINCT mgr),COUNT(mgr)

FROM SCOTT.EMP

 

MAX([{DISTINCT|ALL}]<x>) 求返回行的指定列的最大?/FONT> SELECT MAX(sal),MAX(DISTINCT sal) FROM EMP;
MIN([{DISTINCT|ALL}]<x>) 求返回行的指定列的最?/FONT> SELECT MIN(sal),MIN(DISTINCT sal) FROM EMP;
STDDEV([{DISTINCT|ALL}]<x>) 求返回行的指定列的标准方?/FONT> SELECT STDDEV(sal),STDDEV(DISTINCT sal) FROM EMP;
SUM() 求返回行的指定列的和 SELECT SUM(sal) FROM EMP;
VARIANCE() 求返回行的指定列的差异?/FONT>  

 

 

     注意Q?/FONT>

A?SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 9pt; FONT-STYLE: normal; FONT-FAMILY: Times New Roman; FONT-VARIANT: normal"> 分组函数不会处理I|也不会返回空?/SPAN>Q?/FONT>

B?FONT size=2>  所有的分组函数既可以作用于指定列的所有gQ也可以只作用于指定列的差异列gQ?/FONT>

C?SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 9pt; FONT-STYLE: normal; FONT-FAMILY: Times New Roman; FONT-VARIANT: normal"> 当指?/SPAN>ALL选项Ӟ分组函数作用于所有非I列D上。当指定DISTINCT选项Ӟ分组函数只作用于非空的且h不同列值的行上Q即Q重复列值的行只计算一行)Q?BR>转自Q?A >http://www.pcptel.com/content/view/66/30/



]]>
connect by构徏旉D表http://www.aygfsteel.com/piliskys/archive/2005/11/23/21158.html霚w?/dc:creator>霚w?/author>Wed, 23 Nov 2005 09:44:00 GMThttp://www.aygfsteel.com/piliskys/archive/2005/11/23/21158.htmlhttp://www.aygfsteel.com/piliskys/comments/21158.htmlhttp://www.aygfsteel.com/piliskys/archive/2005/11/23/21158.html#Feedback1http://www.aygfsteel.com/piliskys/comments/commentRss/21158.htmlhttp://www.aygfsteel.com/piliskys/services/trackbacks/21158.html
select to_char(to_date('200105','yyyymm'),'yyyy')+ b.bb||'00'+a.aa  ff
     
from 
    (
select level aa from dual connect by 1=1 and level <13 ) a, 
    (
select level-1 bb from dual connect by 1=1 and level <=
    (to_char(to_date(
'200402','yyyymm'),'yyyy'- to_char(to_date('200105','yyyymm'),'yyyy')+1)  ) b
    
where  to_char(to_date('200105','yyyymm'),'yyyy')+ b.bb||'00'+a.aa  >='200105'
    
and to_char(to_date('200105','yyyymm'),'yyyy')+ b.bb||'00'+a.aa  <='200402'

不用其它表,可以构造出一个时间表?注意Qconnect by据说只支持oracle 9i 及以?img src ="http://www.aygfsteel.com/piliskys/aggbug/21158.html" width = "1" height = "1" />

]]>
վ֩ģ壺 բ| ̨| | | | | | ʡ| | | ͭ| | ƽ̶| | | | ʻ| | ֣| | | ̩| | | ˮ| ǿ| ͬ| ˳| | | | | | | | пǰ| | ̩| ԭ| | ɽ|