Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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È«½Ç/°ë½Çת»»

if   exists   (select   *   from   dbo.sysobjects   where   id   =   object_id(N'[dbo].[f_convert]')   and   xtype   in   (N'FN',   N'IF',   N'TF'))&n ......

sql server·Ö²¼Ê½ÊÂÎñ½â¾ö·½°¸

ÊÊÓû·¾³
²Ù×÷ϵͳ£ºwindows 2003
Êý¾Ý¿â£ºsql server 2000/sql server 2005
ʹÓÃÁ´½Ó·þÎñÆ÷½øÐÐÔ¶³ÌÊý¾Ý¿â·ÃÎʵÄÇé¿ö
Ò»¡¢  ÎÊÌâÏÖÏó
ÔÚÖ´Ðзֲ¼Ê½ÊÂÎñʱ£¬ÔÚsql server 2005ÏÂÊÕµ½ÈçÏ´íÎó£º
ÏûÏ¢ 7391£¬¼¶±ð 16£¬×´Ì¬ 2£¬¹ý³Ì xxxxx£¬µÚ 16 ÐÐ
ÎÞ·¨Ö´ÐиòÙ×÷£¬ÒòΪÁ´½Ó·þÎñÆ÷ "xxxxx" µÄ OLE DB ·ÃÎÊ½Ó¿Ú " ......

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

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

SQLÇó½â°Ë»ÊºóÎÊÌ⣨92ÖÖ½á¹û£©

--¸Ã±í±£´æ½á¹û
create table c(c1 tinyint, c2 tinyint, c3 tinyint, c4 tinyint, c5 tinyint, c6 tinyint, c7 tinyint, c8 tinyint, c9 tinyint, c10 tinyint, c11 tinyint, c12 tinyint, c13 tinyint, c14 tinyint, c15 tinyint, c16 tinyint, c17 tinyint, c18 tinyint, c19 tinyint, c20 tinyint, c21 tinyint, c22 t ......

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

1.
     SQL> desc gjh_a05 ;
Name  Type          Nullable Default Comments
----- ------------- -------- ------- --------
A0500 VARCHAR2(2)   Y           &nbs ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ