Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

SQL¾«»ªÊÕ¼¯

order by µÄÊýÖµÐÍÁé»îʹÓÃ
select * from table_a where id=p_id order by decode(º¯Êý,'asc',1,'desc',-1)*jsny;
¿ØÖÆÊÔͼµÄ·ÃÎÊʱ¼ä£º
6.create view ...
as
select ... from where exists(select x from dual where sysdate>=8:00am and sysdate<=5:00pm)
ÃîÓÃdecodeʵÏÖÅÅÐò
select * from tabname
order by decode(mode,'FIFO',1,-1)*to_char(rq,'yyyymmddhh24miss');
select * from tabname
order by decode(mode,'FIFO',rq-sysdate, sysdate-rq)
ÕÒ³öij¸öʱÆÚÄÚ¹¤×÷ÈÕÊý£º
select count(*)
from ( select rownum-1 rnum
from all_objects
where rownum <= to_date('2002-02-28','yyyy-mm-dd') - to_date('2002-
02-01','yyyy-mm-dd')+1 )
where to_char( to_date('2002-02-01','yyyy-mm-dd')+rnum-1, 'D' ) not
in ( '1', '7' )
ÎÒ¾õµÃ²éÑ¯ÖØ¸´¼Ç¼µÄÓï¾ä¾ÍºÜ¾­µä
select rowid,bdsszd from BADWDJ a where a.rowid != (select max(rowid) from BADWDJ b where a.bdsszd =b.bdsszd)
ÓÉËüÒýÉêµÄ¾ÍÓкܶàÓÐÓõÄÓï¾ä£¬Èç×òÌì»Ø´ð±ðÈ˵ÄÅÅÐòµÄÄÑÌâ
select id,bdsszd from BADWDJ a where a.id = (select max(id) from BADWDJ b where a.bdsszd =b.bdsszd) order by id
Ê÷Ðͽṹ±íµÄ²éѯ£º
select ID,PARENT_ID from parent_child
connect by prior id = parent_id
start with id = 1;
1.decodeÕâ¸öº¯ÊýÒ»¶¨ÐèÒª»á£¬ÎÒ¾õµÃsqlµÄÁé»îºÜ¶àµØ·½¶¼ÊÇͨ¹ýÕâ¸öfunctionÀ´ÌåÏֵģ¬Ï൱ÓÚif£¬ºÜºÃÓá£
2.group by£¬Õâ¸ö¶«¶«ÏëÏë¼òµ¥£¬ÆäʵºÃ¶àͳ¼Æ¹¦ÄÜÊÇÀë²»¿ªÕâ¸ö²Ù×÷µÄ¡£oracle8ÖÐÀ©³äÁËgroup by rollupºÍcubeµÄ²Ù×÷¡£ÓÐʱºòÊ¡ÁËÄãºÃ¶à¹¦·òµÄ¡£ÖµµÃ×¢ÒâµÄÊÇ£¬µ±Äã¶ÔÊÂÎï×ö¹ýÓÐЧµÄÈËΪ¹é²¢Ö®ºóÖ´ÐÐgroup by ÍùÍù»á¸üÈÃÈËÐÄ¿õÉñâù¡£
3.ºÜ±íÊúÖõľ­µäд·¨£¬Ò²Òª¼Çס£ºsum(decode( )) group by ...
×¢Ò⣺ÐèÒªÔÚÒ»¸ösubqueryÖÐÈ·¶¨Ò»¸öºáÖÃÅе㡣
4.Ê÷Ðνṹ±íµÄ±éÀúд·¨£ºselect ...from ....
start with ... connect by prior (¸¸×Ó¹ØÏµ±í´ïʽ)
select * from xxx where decode(:var,null,'0',column1) = decode(:var,null,'0',:var);
816ÒÔÉÏµÄ Ò»Ð©·ÖÎöº¯ÊýÈç rank() over() and row_number() over()
µ±È»¹ØÓÚ group by rollup/cubeʹÓõÄÈË¿ÖÅÂÌØ±ðÉÙ
ÈçºÎʵÏÖ×î´óÆ¥ÅäµÄ²Ù×÷?
ÀýÈç:¸ø¶¨×Ö·û´® '1234', ¶ø±íÖпÉÄÜÓмǼÏî'1','12','123','1234','12345',Ҫѡ³ö'


Ïà¹ØÎĵµ£º

SQL ¶à±íÁªºÏ²éѯ

ºÜÉÙÓÃjoin£¬Õâ´Îѧѧ£¬²¢±¸ÍüÁ½ÆªÎÄÕ£¡
ת×Ô£ºhttp://hcx-2008.javaeye.com/blog/285661
Á¬½Ó²éѯ
ͨ¹ýÁ¬½ÓÔËËã·û¿ÉÒÔʵÏÖ¶à¸ö±í²éѯ¡£Á¬½ÓÊǹØÏµÊý¾Ý¿âÄ£Ð͵ÄÖ÷ÒªÌØµã£¬Ò²ÊÇËüÇø±ðÓÚÆäËüÀàÐÍÊý¾Ý¿â¹ÜÀíϵͳµÄÒ»¸ö±êÖ¾¡£
ÔÚ¹ØÏµÊý¾Ý¿â¹ÜÀíϵͳÖУ¬±í½¨Á¢Ê±¸÷Êý¾ÝÖ®¼äµÄ¹ØÏµ²»±ØÈ·¶¨£¬³£°ÑÒ»¸öʵÌåµÄËùÓÐÐÅÏ¢´æ·ÅÔÚÒ ......

pl/sql Óï¾äµÄ¼¸µãÓÅ»¯

1.
     SQL> desc gjh_a05 ;
Name  Type          Nullable Default Comments
----- ------------- -------- ------- --------
A0500 VARCHAR2(2)   Y           &nbs ......

»ñÈ¡SQL ServerËùÓÐÊý¾Ý¿âÃû£¬±íÃû£¬×Ö¶ÎÃû


/*
 * Source URL: http://jonsion.javaeye.com/blog/511584
 */
1. »ñÈ¡ËùÓÐÊý¾Ý¿âÃû
1> SELECT name from master..sysdatabases;
2> go
2. »ñÈ¡ËùÓбíÃû
1> USE master
2> go
1> SELECT name from sysobjects WHERE type='U';
2> go
3. »ñÈ¡ËùÓÐ×Ö¶ÎÃû
1> SELECT name ......

SQL·Ö¸î¶ººÅµÄº¯ÊýºÍÓ÷¨

      ÔÚ³ÌÐòÖÐÎÒÃÇ¿ÉÄܾ­³£»áÓöµ½ÕâÖÖÇé¿ö£¬±ÈÈçҪȡһ¸ölistboxÀïÃæµÄÑ¡ÔñÏµÃµ½µÄ½á¹û¿ÉÄÜÊÇstring ID="id1,id2,id3,id4",È»ºóÎÒÃÇÒª°ÑÕâЩID²åÈëµ½Êý¾Ý¿âÖУ¬Í¬Ê±Ã¿¸öid¶ÔÓ¦µÄÊÇÒª²åÈëÒ»Ìõ¼Ç¼¡£ÊµÏֵķ½·¨Óкܶ࣬µ«ÊÇÈç¹ûÎÒÃÇͨ¹ýÏÂÃæÕâ¸öº¯Êý£¨RecurrentSplit£©¾ÍÄܼòµ¥µÄ´ïµ½ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ