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

ORACLE ORDER BYÓ÷¨×ܽá

½ñÌìÔÚ¹äÂÛ̳µÄʱºò¿´µ½shiyiwanͬѧдÁËÒ»¸öºÜ¼òµ¥µÄÓï¾ä£¬¿ÉÊÇorder byºóÃæµÄÐÎʽȴ±È½ÏÐÂÓ±£¨¶ÔÓÚÎÒÀ´ËµÅ¶£©£¬ÒÔÇ°´ÓÀ´Ã»¿´¹ýÕâÖÖÓ÷¨£¬¾ÍÏë¼ÇÏÂÀ´£¬ÕýºÃ×ܽáÒ»ÏÂORDER BYµÄ֪ʶ¡£
1¡¢ORDER BY ÖйØÓÚNULLµÄ´¦Àí
ȱʡ´¦Àí£¬OracleÔÚOrder by ʱÈÏΪnullÊÇ×î´óÖµ£¬ËùÒÔÈç¹ûÊÇASCÉýÐòÔòÅÅÔÚ×îºó£¬DESC½µÐòÔòÅÅÔÚ×îÇ°¡£
µ±È»£¬ÄãÒ²¿ÉÒÔʹÓÃnulls first »òÕßnulls last Óï·¨À´¿ØÖÆNULLµÄλÖá£
Nulls firstºÍnulls lastÊÇOracle Order byÖ§³ÖµÄÓï·¨
Èç¹ûOrder by ÖÐÖ¸¶¨Á˱í´ïʽNulls firstÔò±íʾnullÖµµÄ¼Ç¼½«ÅÅÔÚ×îÇ°(²»¹ÜÊÇasc »¹ÊÇ desc)
Èç¹ûOrder by ÖÐÖ¸¶¨Á˱í´ïʽNulls lastÔò±íʾnullÖµµÄ¼Ç¼½«ÅÅÔÚ×îºó (²»¹ÜÊÇasc »¹ÊÇ desc)
ʹÓÃÓï·¨ÈçÏ£º
--½«nullsʼÖÕ·ÅÔÚ×îÇ°
select * from zl_cbqc order by cb_ld nulls first
--½«nullsʼÖÕ·ÅÔÚ×îºó
select * from zl_cbqc order by cb_ld desc nulls last
2¡¢¼¸ÖÖÅÅÐòµÄд·¨
µ¥ÁÐÉýÐò£ºselect<column_name> from <table_name> order by <column_name>; £¨Ä¬ÈÏÉýÐò£¬¼´Ê¹²»Ð´ASC£©
µ¥ÁнµÐò£ºselect <column_name> from <table_name> order by <column_name> desc;
¶àÁÐÉýÐò£ºselect <column_one>, <column_two> from <table_name> order by <column_one>, <column_two>;
¶àÁнµÐò£ºselect <column_one>, <column_two> from <table_name> order by <column_one> desc, <column_two> desc;
¶àÁлìºÏÅÅÐò£ºselect <column_one>, <column_two> from <table_name> order by <column_one> desc, <column_two> asc;
3¡¢½ñÌì¿´µ½µÄÐÂд·¨
SQL> select * from tb;
    BLOGID BLOGCLASS
---------- ------------------------------
        1 ÈËÉú
        2 ѧϰ
        3 ¹¤×÷
        5 ÅóÓÑ
SQL> select * from tb order by decode(blogid,3,1,2), blogid;
    BLOGID BLOGCLASS
---------- ------------------------------
        3 ¹¤×÷
        1 ÈËÉú
        2 ѧϰ
        5 ÅóÓÑ
ÎÒËù˵µÄ¾ÍÊÇÉÏÃæºìÉ«µ


Ïà¹ØÎĵµ£º

OracleÈÕÆÚº¯Êý£º

 select sysdate from dual; ´Óα±í²éϵͳʱ¼ä£¬ÒÔĬÈϸñʽÊä³ö¡£
sysdate+(5/24/60/60) ÔÚϵͳʱ¼ä»ù´¡ÉÏÑÓ³Ù5Ãë
sysdate+5/24/60 ÔÚϵͳʱ¼ä»ù´¡ÉÏÑÓ³Ù5·ÖÖÓ
sysdate+5/24 ÔÚϵͳʱ¼ä»ù´¡ÉÏÑÓ³Ù5Сʱ
sysdate+5 ÔÚϵͳʱ¼ä»ù´¡ÉÏÑÓ³Ù5Ìì
ËùÒÔÈÕÆÚ¼ÆËãĬÈϵ¥Î»ÊÇÌì
round (sysdate,’day’) ²»ÊÇËijý ......

Oracle Åú´¦ÀíÆô¶¯¹Ø±Õ·þÎñ

 OracleÔÚ×Ô¼º»úÆ÷ÉÏ×°Ò»¸öÓбØÒªµÄ£¬±Ï¾¹ÓÐʱºòÐèÒª×Ô¼ºÔÚ¼ÒѧϰһÏ£¬µ«µçÄÔ²»ÊÇ×Ô¼ºÓõģ¬»¹ÊÇд¸öÅú´¦Àí½â¾öһϣ¬ÐèÒªµÄʱºòµã»÷Ò»ÏÂÆô¶¯£¬²»ÐèÒª¾ÍÍ£Ö¹£¬ºÜ·½±ã¡£ÕâÀォ½Å±¾¸ø´ó¼Òдһ¸ö£¬»¶Ó­´ó¼ÒÕ³Ìù¿½±´¡£
Ê×ÏÈ£¬×Ô¼ºÏȽ«×Ô¼ºµÄ×Ô¶¯Æô¶¯·þÎñ¹Ø±Õ£¬²¢¼Ç¼һÏ£¬È»ºóÌæ»»½Å±¾ÖÐÏàÓ¦µÄ·þÎñÃû³Æ¼´¿É¡£×Ô¼ºÕ³Ìù³ö ......

OracleÖÐ×éºÏË÷ÒýµÄʹÓÃÏê½â

ÔÚOracleÖпÉÒÔ´´½¨×éºÏË÷Òý£¬¼´Í¬Ê±°üº¬Á½¸ö»òÁ½¸öÒÔÉÏÁеÄË÷Òý¡£ÔÚ×éºÏË÷ÒýµÄʹÓ÷½Ã棬OracleÓÐÒÔÏÂÌص㣺
    1¡¢ µ±Ê¹ÓûùÓÚ¹æÔòµÄÓÅ»¯Æ÷£¨RBO£©Ê±£¬Ö»Óе±×éºÏË÷ÒýµÄÇ°µ¼ÁгöÏÖÔÚSQLÓï¾äµÄwhere×Ó¾äÖÐʱ£¬²Å»áʹÓõ½¸ÃË÷Òý£»
    2¡¢ ÔÚʹÓÃOracle9i֮ǰµÄ»ùÓڳɱ¾µÄÓÅ»¯Æ÷£¨CBO£©Ê± ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ