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

ÊìÁ·OracleµÄSqlÓï¾ä±Ø×ö18µÀ

 Ê¹ÓÃscott/tigerÓû§ÏµÄemp±íºÍdept±íÍê³ÉÏÂÁÐÁ·Ï°£¬±íµÄ½á¹¹ËµÃ÷ÈçÏÂ
empÔ±¹¤±í(empnoÔ±¹¤ºÅ/enameÔ±¹¤ÐÕÃû/job¹¤×÷/mgrÉϼ¶±àºÅ/hiredateÊܹÍÈÕÆÚ/salн½ð/commÓ¶½ð/deptno²¿ÃűàºÅ)
dept²¿Ãűí(deptno²¿ÃűàºÅ/dname²¿ÃÅÃû³Æ/locµØµã)
¹¤×Ê £½ н½ð £« Ó¶½ð
1£®ÁгöÖÁÉÙÓÐÒ»¸öÔ±¹¤µÄËùÓв¿ÃÅ
2£®Áгöн½ð±È“SMITH”¶àµÄËùÓÐÔ±¹¤¡£
3£®ÁгöËùÓÐÔ±¹¤µÄÐÕÃû¼°ÆäÖ±½ÓÉϼ¶µÄÐÕÃû¡£
4£®ÁгöÊܹÍÈÕÆÚÍíÓÚÆäÖ±½ÓÉϼ¶µÄËùÓÐÔ±¹¤¡£
5£®Áгö²¿ÃÅÃû³ÆºÍÕâЩ²¿ÃŵÄÔ±¹¤ÐÅÏ¢£¬Í¬Ê±ÁгöÄÇЩûÓÐÔ±¹¤µÄ²¿ÃÅ¡£
6£®ÁгöËùÓГCLERK”£¨°ìÊÂÔ±£©µÄÐÕÃû¼°Æ䲿ÃÅÃû³Æ¡£
7£®Áгö×îµÍн½ð´óÓÚ1500µÄ¸÷ÖÖ¹¤×÷¡£
8£®ÁгöÔÚ²¿ÃÅ“SALES”£¨ÏúÊÛ²¿£©¹¤×÷µÄÔ±¹¤µÄÐÕÃû£¬¼Ù¶¨²»ÖªµÀÏúÊÛ²¿µÄ²¿ÃűàºÅ¡£
9£®Áгöн½ð¸ßÓÚ¹«Ë¾Æ½¾ùн½ðµÄËùÓÐÔ±¹¤¡£
10£®ÁгöÓë“SCOTT”´ÓÊÂÏàͬ¹¤×÷µÄËùÓÐÔ±¹¤¡£
11£®Áгöн½ðµÈÓÚ²¿ÃÅ30ÖÐÔ±¹¤µÄн½ðµÄËùÓÐÔ±¹¤µÄÐÕÃûºÍн½ð¡£
12£®Áгöн½ð¸ßÓÚÔÚ²¿ÃÅ30¹¤×÷µÄËùÓÐÔ±¹¤µÄн½ðµÄÔ±¹¤ÐÕÃûºÍн½ð¡£
13£®ÁгöÔÚÿ¸ö²¿ÃŹ¤×÷µÄÔ±¹¤ÊýÁ¿¡¢Æ½¾ù¹¤×ʺÍƽ¾ù·þÎñÆÚÏÞ¡£
14£®ÁгöËùÓÐÔ±¹¤µÄÐÕÃû¡¢²¿ÃÅÃû³ÆºÍ¹¤×Ê¡£
16£®ÁгöËùÓв¿ÃŵÄÏêϸÐÅÏ¢ºÍ²¿ÃÅÈËÊý¡£
17£®Áгö¸÷ÖÖ¹¤×÷µÄ×îµÍ¹¤×Ê¡£
18£®ÁгöMANAGER£¨¾­Àí£©µÄ×îµÍн½ð¡£
19£®ÁгöËùÓÐÔ±¹¤µÄÄ깤×Ê,°´Äêн´ÓµÍµ½¸ßÅÅÐò¡£
===============================================
ʹÓÃscott/tigerÓû§ÏµÄemp±íºÍdept±íÍê³ÉÏÂÁÐÁ·Ï°£¬±íµÄ½á¹¹ËµÃ÷ÈçÏÂ
empÔ±¹¤±í(empnoÔ±¹¤ºÅ/enameÔ±¹¤ÐÕÃû/job¹¤×÷/mgrÉϼ¶±àºÅ/hiredateÊܹÍÈÕÆÚ/salн½ð/commÓ¶½ð/deptno²¿ÃűàºÅ)
dept²¿Ãűí(deptno²¿ÃűàºÅ/dname²¿ÃÅÃû³Æ/locµØµã)
¹¤×Ê £½ н½ð £« Ó¶½ð
------1£®ÁгöÖÁÉÙÓÐÒ»¸öÔ±¹¤µÄËùÓв¿ÃÅ
select * from dept
where deptno in
(select deptno from emp group by deptno having count(*)>1);
------2£®Áгöн½ð±È“SMITH”¶àµÄËùÓÐÔ±¹¤¡£
select * from emp
where sal>(select sal from emp where ename='SMITH');
------3£®ÁгöËùÓÐÔ±¹¤µÄÐÕÃû¼°ÆäÖ±½ÓÉϼ¶µÄÐÕÃû¡£
select ename,(select ename from emp where empno=a.mgr) from emp a;
»ò
 select ename, (select ename from emp where empno=a.mgr) as mgrname from emp a;
×ÔÁ¬½Ó
select a.ename,b.ename from emp a,emp b
where a.mgr=b.empno(+)


Ïà¹ØÎĵµ£º

oracle ÐÐתÁеÄͨÓùý³Ì

 Ô­ÎÄ´«ËÍÃÅ£ºhttp://topic.csdn.net/u/20091019/11/67cd55a3-3f42-4db7-a3f8-91dd52a913cd.html?24122
¾­³£Óöµ½·¢ÌûÇóÐÐÁÐת»»µÄ´úÂ룬ÓÃmax(decode(..))»Ø¸´ºó£¬Ê®Óа˾ŻáÔÙÎÊÒ»¾ä£ºÈç¹ûÁÐÃû²»¹Ì¶¨£¬»òÕßÁÐÊý²»¹Ì¶¨Ôõô°ì¡£¾ÍÒªÓô洢¹ý³ÌÀ´Ð´£¬ÕâЩ´æ´¢¹ý³ÌµÄ´úÂ붼´óͬСÒ죬ÎÒ¾ÍÏëÄܲ»ÄÜд¸öͨÓõãµÄ¹ý³Ì
ÊÔÁ ......

ÔÚSQL ServerÓ¦ÓÃÖÐʹÓÃOUTPUT×Ó¾ä

 ÏÖÔÚ´ó¶àÊýÃèÊöSQL Server 2005ÐÂÌØÐÔµÄÎÄÕ¶¼¹Ø×¢ÓÚ»ª¶ø²»ÊµµÄÌØÐÔ£¬ÈçSQLCLR»òXMLÊý¾ÝÀàÐÍ£¬¶ø¶ÔÐí¶àºÜºÃµÄÀϵÄT-SQLÓïÑԵĸĽøûÓеõ½Ó¦ÓеĹØ×¢¡£ÎÒÔø¾­´ÓÐí¶àDBA¿ÚÖÐÌýµ½ÁîËûÃǸüÐ˷ܵÄÊÇ¿´µ½T-SQLÓïÑԵĸĽø,¶ø²»ÊÇÄÇЩгöÏֺͷ¢²¼µÄ¹¦ÄÜ¡£¶ÔÓÚSQLÓïÑÔµÄÒ»¸öºÜÓÐÓõÄʵ¼Ê¸Ä½øÊÇOUTPUT×Ӿ䣬ËüÔÊÐí²éѯһ¸öÊý¾ ......

ÓÃSQL Server 2005 CTE¼ò»¯²éѯ

SQL Server 2005Òý½øÁËÒ»¸öºÜÓмÛÖµµÄеÄTransact-SQLÓïÑÔ×é¼þ£ºÒ»¸öͨÓñí±í´ïʽ£¨Common Table Expression£¬CTE£©£¬ËüÊÇÅÉÉú±íºÍÊÓͼµÄÒ»¸ö±ã½ÝµÄÌæ´ú¡£Í¨¹ýʹÓÃCTE£¬ÎÒÃÇ¿ÉÒÔ´´½¨Ò»¸öÃüÃû½á¹û¼¯À´ÔÚSELECT¡¢INSERT¡¢UPDATEºÍDELETEÓï¾äÖÐÒýÓ㬶øÎÞÐë±£´æ½á¹û¼¯½á¹¹µÄÈκÎÔªÊý¾Ý¡£ÔÚ±¾ÎÄÖУ¬ÎÒ½«²ûÊöÈçºÎÔÚSQL Server 2 ......

ÉîÈëÑо¿SQL SERVER 2005ºÍ¶à»î¶¯½á¹û¼¯£¨MARS£©

SQL SERVER 2005ÒýÈëÁËÔÚµ¥Ò»Á¬½ÓÉ϶Զà»î¶¯½á¹û¼¯£¨Ò²³ÆΪMARS£©»ò¶à¸öÇëÇóµÄÖ§³Ö¡£Í¨¹ýÔÚÓëSQL SERVER 2005µÄÁ¬½ÓÉÏÆôÓÃÕâÒ»ÌØÐÔ£¬µ±´æÔÚÓëSqlconnectionÏà¹ØÁªµÄ¿ª·ÅʽSqlDataReaderʱ£¬Á¬½Ó½«²»»áÖжϡ£¼´Ê¹ÉÐδ¹Ø±Õµ±Ç°´ò¿ªµÄSqlDataReader£¬Ò²ÈÔÈ»Äܹ»ÔÚSqlconnectionÉÏÖ´ÐÐÆäËû²éѯ±ÈÈ磺SELECT£¬UPDATE£¬CREATETABL ......

SQL SERVER¶¨Ê±×÷ÒµµÄÉèÖ÷½·¨

         SQL SERVER¶¨Ê±×÷ÒµµÄÉèÖ÷½·¨
תÌù×Ô£º http://www.cnblogs.com/stephencat/archive/2006/08/24/484918.html
 Èç¹ûÔÚSQL Server ÀïÐèÒª¶¨Ê±»òÕßÿ¸ôÒ»¶Îʱ¼äÖ´ÐÐij¸ö´æ´¢¹ý³Ì»ò3200×Ö·ûÒÔÄÚµÄSQLÓï¾äʱ,
¿ÉÒÔÓùÜÀí->SQL Server´úÀí->×÷ÒµÀ´ÊµÏÖ¡£
1¡¢¹ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ