ORACLE´Ó±íÖÐËæ»ú·µ»ØnÌõ¼Ç¼
ʹÓÃORDER BY×Ӿ䣬ROWNUMÄÚÖú¯ÊýºÍDBMS_RANDOM°üÖеÄÄÚÖú¯ÊýVALUEÀ´ÊµÏÖ
SQL> select * from
2 (
3 select ename,job
4 from emp
5 order by dbms_random.value()
6 )
7 where rownum<=5;
ENAME JOB
---------- ---------
TURNER SALESMAN
SMITH CLERK
MARTIN SALESMAN
BLAKE MANAGER
SCOTT ANALYST
SQL> /
ENAME JOB
---------- ---------
ALLEN SALESMAN
SMITH CLERK
WARD SALESMAN
MARTIN SALESMAN
SCOTT ANALYST
Ïà¹ØÎĵµ£º
ѧϰOracle DBAÒ²°ë¸ö¶àѧÆÚÁË£¬½ñÌìÃÍÈ»²Å·¢ÏÖ£¬ÔÀ´ÎÒµÄÊ黹ÊǺÜеģ¬ÉϿβÙ×÷ʱºòÒ²Ö»ÊÇÖªµÀ´ó¸ÅÔõô×ö£¬µ«ÊÇÒªÕæµÄÈ«²¿×Ô¼º×ö£¬¶ø²»È¥·Ê黹ÊÇÓÐÒ»¶¨µÄÄѶȵģ¬ËùÒÔÄØ£¬½ñÌ쿪ʼ½«DBA´ÓÍ·¸´Ï°Ò»±é£¬Í¬Ê±ÔÙ²Ù×÷Ò»±é¡£
µÚÒ»Õ£¬Ñ§µÄÊÇOracleµÄÌåϵ½á¹¹£ ......
select t.lot_number
from inv.mtl_onhand_quantities_detail t
left join mtl_system_items_b mi
on t.inventory_item_id = mi.inventory_item_id
where mi.segment1 like '101%' and mi.organization_id = 102
group by t.lot_number having count(*)=1 union
select t.lot_number||'x'
......
²éѯ±íempÖÐËùÓÐÊý¾Ý
select emp_id,rownum from emp
µÚÒ»²½£¬²éѯ½á¹û,rownum´ý¶¨
emp_id rownum
1 ? 1
2 ? 2
3 ? 3
4&n ......
Ò»¸ö±íÖÐÓм¸°ÙÍòÌõÊý¾Ý£¬¶Ôij¸ö×ֶμÓÁËË÷Òý£¬µ«ÊDzéѯʱÐÔÄܲ¢Ã»ÓÐʲôÌá¸ß£¬ÕâÖ÷Òª¿ÉÄÜÊÇoracleµÄË÷ÒýÏÞÖÆÔì³ÉµÄ¡£
¡¡¡¡oracleµÄË÷ÒýÓÐһЩË÷ÒýÏÞÖÆ£¬ÔÚÕâЩË÷ÒýÏÞÖÆ·¢ÉúµÄÇé¿öÏ£¬¼´Ê¹ÒѾ¼ÓÁËË÷Òý£¬oracle»¹ÊÇ»áÖ´ÐÐÒ»´ÎÈ«±íɨÃ裬²éѯµÄÐÔÄܲ»»á±È²»¼ÓË÷ÒýÓÐËùÌá¸ß£¬·´¶ø¿ÉÄÜÓÉÓÚÊý¾Ý¿âά»¤Ë÷ÒýµÄϵͳ¿ªÏúÔì³ÉÐÔÄܸ ......
×î¼òµ¥µÄÊÇʹÓÃ
/* Formatted on 2009/12/02 16:01 (Formatter Plus v4.8.8) */
SELECT TO_CHAR (TO_DATE ('2009-12-02', 'YYYY-MM-DD'), 'WW')
from DUAL;
²»¹ýto_char()º¯ÊýÔÚ¼ÆËãÒ»ÄêÖеڼ¸ÖÜÊÇ´Ó¸ÃÄêµÄ1ÔÂ1ÈÕ¿ªÊ¼µÄ¡£
ÒÔÏÂSQL Äܵõ½ÕýÈ·µÄ×ÔÈ»ÖÜÊý.
/* Formatted ......