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

sql having ºÍwhereµÄÇø±ð

  ×î½üÔÚѧϰoracleµÄʱºòÓöµ½Ò»¸öÎÊÌ⣬ÀÏÊÇŪ²»Çå³þwhere ºÍhavingµÄÇø±ð£¬ÔÚÍøÉϲéÒ»²é£¬¸Ð¾õ»¹¿ÉÒÔ£¬°ÑÒÔÏÂÎÒ²éµÄ×ÊÁÏÍƼö¸ø´ó¼Ò¡£
ÔÚselect Óï¾äÖпÉÒÔʹÓÃgroup by ×Ӿ佫Ðл®·Ö³É½ÏСµÄ×飬Ȼºó£¬Ê¹ÓþÛ×麯Êý·µ»Øÿһ¸ö×éµÄ»ã×ÜÐÅÏ¢£¬ÁíÍ⣬¿ÉÒÔʹÓÃhaving×Ó¾äÏÞÖÆ·µ»ØµÄ½á¹û¼¯¡£group by ×Ó¾ä¿ÉÒÔ½«²éѯ½á¹û·Ö×飬²¢·µ»ØÐеĻã×ÜÐÅÏ¢Oracle °´ÕÕgroup by ×Ó¾äÖÐÖ¸¶¨µÄ±í´ïʽµÄÖµ·Ö×é²éѯ½á¹û¡£
   ÔÚ´øÓÐgroup by ×Ó¾äµÄ²éѯÓï¾äÖУ¬ÔÚselect ÁбíÖÐÖ¸¶¨µÄÁÐҪôÊÇgroup by ×Ó¾äÖÐÖ¸¶¨µÄÁУ¬ÒªÃ´°üº¬¾Û×麯Êý
   select max(sal),job emp group by job; 
   (×¢Òâmax(sal), job µÄjob²¢·ÇÒ»¶¨Òª³öÏÖ£¬µ«ÓÐÒâÒå )
   ²éѯÓï¾äµÄselect ºÍgroup by ,having ×Ó¾äÊǾÛ×麯ÊýΨһ³öÏֵĵط½£¬ÔÚwhere ×Ó¾äÖв»ÄÜʹÓþÛ×麯Êý¡£
  select deptno,sum(sal) from emp where sal>1200 group by deptno having sum(sal)>8500 order by deptno;
  µ±ÔÚgropu by ×Ó¾äÖÐʹÓÃhaving ×Ó¾äʱ£¬²éѯ½á¹ûÖÐÖ»·µ»ØÂú×ãhavingÌõ¼þµÄ×é¡£ÔÚÒ»¸ösqlÓï¾äÖпÉÒÔÓÐwhere×Ó¾äºÍhaving×Ӿ䡣having Óëwhere ×Ó¾äÀàËÆ£¬¾ùÓÃÓÚÉèÖÃÏÞ¶¨Ìõ¼þ 
ÎÒ¾ÍÒÔÎÒ×öµÄt_studentѧÉú±íΪÀý £¬ÀïÃæÓÐ×ֶΣºÑ§ºÅ£¨sno£©£¬¿ÆÄ¿(subject)£¬·ÖÊý(score),
±ÈÈçÎÒÒª²éѯ²Î¼Ó¿¼ÊÔ¸÷¿Æ³É¼¨¶¼¼°¸ñµÄѧԱ“ѧºÅ”£¬“ƽ¾ù³É¼¨”
select sno,avg(score) from t_score group by sno having min(score)>=60;
Ò²¾ÍÊÇ˵£¬ÏÈ°´Ñ§ºÅ½øÐзÖ×飬·Ö×éºÃÒÔºó£¬È»ºóÔÚÕÒ³ö·ûºÏÌõ¼þµÄÒ»×飬
½á¹ûÈçÏ£º
SNO AVG(SCORE)
------ -----------------
y2010 76
 where ×Ó¾äµÄ×÷ÓÃÊÇÔÚ¶Ô²éѯ½á¹û½øÐзÖ×éÇ°£¬½«²»·ûºÏwhereÌõ¼þµÄÐÐÈ¥µô£¬¼´ÔÚ·Ö×é֮ǰ¹ýÂËÊý¾Ý£¬Ìõ¼þÖв»ÄÜ°üº¬¾Û×麯Êý£¬Ê¹ÓÃwhereÌõ¼þÏÔʾÌض¨µÄÐС£
  having ×Ó¾äµÄ×÷ÓÃÊÇɸѡÂú×ãÌõ¼þµÄ×飬¼´ÔÚ·Ö×éÖ®ºó¹ýÂËÊý¾Ý£¬Ìõ¼þÖо­³£°üº¬¾Û×麯Êý£¬Ê¹ÓÃhaving Ìõ¼þÏÔʾÌض¨µÄ×飬Ҳ¿ÉÒÔʹÓöà¸ö·Ö×é±ê×¼½øÐзÖ×é¡£
´ó¼Ò¿ÉÒÔ½¨


Ïà¹ØÎĵµ£º

sqlÓï¾äÓÅ»¯Ô­Ôò

1.¶àwhere£¬ÉÙhaving
whereÓÃÀ´¹ýÂËÐУ¬havingÓÃÀ´¹ýÂË×é
2.¶àunion all£¬ÉÙunion
unionɾ³ýÁËÖظ´µÄÐУ¬Òò´Ë»¨·ÑÁËһЩʱ¼ä
3.¶àExists£¬ÉÙin
ExistsÖ»¼ì²é´æÔÚÐÔ£¬ÐÔÄܱÈinÇ¿ºÜ¶à£¬ÓÐЩÅóÓѲ»»áÓÃExists£¬¾Í¾Ù¸öÀý×Ó
Àý£¬ÏëÒªµÃµ½Óе绰ºÅÂëµÄÈ˵Ļù±¾ÐÅÏ¢£¬table2ÓÐÈßÓàÐÅÏ¢
select * from table1;--(id,n ......

µ¼³öÊý¾Ý¡¢Éú³ÉSQL INSERTµÄ·½·¨¡£

ÔÚ¹¤×÷Öг£³£Åöµ½ÕâÖÖÇé¿ö£ºÎÒÃÇÐèÒª½«Ò»¸öÓ¦ÓÃϵͳµÄ»ù´¡Êý¾Ýµ¼³öÀ´£¬ÒÔ±ã»ù´¡Êý¾ÝÏ´ε¼Èëµ½ÁíÍâÒ»¸ö³¡¾°¡£
ÊÂʵÉÏ£¬ÕâÖÖÇé¿öÎÒÃÇ¿ÉÒÔÓÃpl/sqlµÄ¹¦ÄÜExport TablesÀ´ÊµÏÖ¡£Export TableÓÐÈýÖÖµ¼³ö·½Ê½£ºOracle Export£¬SQL Insert£¬PL/SQL Developer¡£Í¨³£ÎÒÃÇ»áʹÓÃOracle Export£¬SQL InsertµÄ¹¦ÄÜ¡£(µÚÈýÖÖ°³Ã»Óùý£¬ ......

ʹÓÃSQLÓï¾ä´´½¨Êý¾Ý¿â


ʹÓÃSQLÓï¾ä´´½¨Êý¾Ý¿â
±¾ÎÄת×Ô£ºhttp://www.cppblog.com/twzheng/archive/2008/07/07/55508.html
      ÓÃCREATE DATABASE´´½¨Êý¾Ý¿âµÄÓï·¨¸ñʽ£º
      CREATE DATABASE database_name   /*Ö¸¶¨Êý¾Ý¿âÃû*/
      [ON× ......

ÖØÐÂÉ趨sql serverÊý¾Ý¿âµÄÓ²Å̱¸·ÝµØÖ·

дÁËÒ»¸öС³ÌÐò£¬Ê¹ÓÃÁËsql server 2005Êý¾Ý¿â£¬µ±Ê±¸ÃÊý¾Ý¿â·Åµ½ÁËC:\Program Files\Microsoft SQL Server\MSSQL.4\MSSQL\DataÏÂÃ棬µ«ÊÇÏÖÔÚ¾õµÃ²»·½±ã£¬Ïë°ÑËüתÒƵ½ÎÒÕâ¸öÍøÕ¾´úÂëËùÔÚµÄÄǸöĿ¼£¬±ÈÈçd£º\network\app_dataÏÂÃ棬ÇëÎÊÔõôת¹ýÈ¥£¬Ð»Ð»£¿
»¹ÓÐÒ»¸öÎÊÌ⣬¾ÍÊÇÎÒ¿´C:\Program Files\Microsoft SQL Serve ......

SybaseµÄSQL Anywhere for BlackBerry

UltraLite®J£ºBlackBerryÉÏÔËÐеÄСÊý¾Ý¿âºÍͬ²½ÒýÇæ
MobiLink £ºÔËÐÐÔÚ·þÎñÆ÷ÉÏÊý¾Ý¿âͬ²½·þÎñÆ÷£¬¿ÉÒÔ°ÑÉ豸ÉϵÄÊý¾Ýͬ²½µ½ºǫ́µÄ¡£°üº¬ÔÚSQL Anywhere 11ÀïÃæ¡£
SQL Anywhere ÊÇÒµÄÚÁìÏȵÄÒƶ¯ºÍǶÈëʽÊý¾Ý¿â£¬ÌṩÊý¾Ý¹ÜÀíºÍ½»»»¼¼Êõ£¬ÎªÒ»Ïß»·¾³ÖеÄÓ¦ÓóÌÐòÌṩ֧³Ö¡£
SQL Anywhere רΪ²»¾ß±¸ÏÖ³¡ IT Ö§³Ö¡¢Ô ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ