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

sql²éѯÁ·Ï°

Àý 34  ÕÒ³öÄêÁ䳬¹ýƽ¾ùÄêÁäµÄѧÉúÐÕÃû¡£
SELECT SNAME
from STUDENTS
WHERE AGE £¾
      (SELECT  AVG(AGE)
        from   STUDENTS)
Àý 35  ÕÒ³ö¸÷¿Î³ÌµÄƽ¾ù³É¼¨£¬°´¿Î³ÌºÅ·Ö×飬ÇÒֻѡÔñѧÉú³¬¹ý 3 È˵Ŀγ̵ijɼ¨¡££¨ GROUP BY Óë HAVING
        GROUP BY ×Ó¾ä°ÑÒ»¸ö±í°´Ä³Ò»Ö¸¶¨ÁУ¨»òһЩÁУ©ÉϵÄÖµÏàµÈµÄÔ­Ôò·Ö×飬ȻºóÔÙ¶Ôÿ×éÊý¾Ý½øÐй涨µÄ²Ù×÷¡£
        GROUP BY ×Ó¾ä×ÜÊǸúÔÚ WHERE ×Ó¾äºóÃæ£¬µ± WHERE ×Ó¾äȱʡʱ£¬Ëü¸úÔÚ from ×Ó¾äºóÃæ¡£
        HAVING ×Ӿ䳣ÓÃÓÚÔÚ¼ÆËã³ö¾Û¼¯Ö®ºó¶ÔÐеIJéѯ½øÐпØÖÆ¡££©
         SELECT CNO, AVG(GRADE), STUDENTS £½ COUNT(*)
         from ENROLLS
         GROUP BY CNO
         HAVING COUNT(*) >= 3
 
Ïà¹Ø×Ó²éѯ
 
Àý 37  ²éѯûÓÐÑ¡Èκογ̵ÄѧÉúµÄѧºÅºÍÐÕÃû¡££¨µ±Ò»¸ö×Ó²éÑ¯Éæ¼°µ½Ò»¸öÀ´×ÔÍⲿ²éѯµÄÁÐʱ£¬³ÆÎªÏà¹Ø×Ó²éѯ£¨ Correlated Subquery) ¡£Ïà¹Ø×Ó²éѯҪÓõ½´æÔÚ²âÊÔν´Ê EXISTS ºÍ NOT EXISTS £¬ÒÔ¼° ALL ¡¢ ANY £¨ SOME £©µÈ¡££©
        SELECT SNO, SNAME
        from   STUDENTS
        WHERE  NOT EXISTS
              (SELECT *
              from ENROLLS
              WHERE ENROLLS.SNO=STUDENTS.SNO)
Àý 38   ²éѯÄÄЩ¿Î³ÌÖ»ÓÐÄÐÉúÑ¡¶Á¡£
        SELECT DISTINCT CNAME
        from   COURSES C
        WHERE ' ÄÐ ' £½ ALL


Ïà¹ØÎĵµ£º

½«±íÊý¾ÝÉú³ÉSQL½Å±¾µÄ´æ´¢¹ý³Ì

CREATE PROCEDURE dbo.UspOutputData
@tablename sysname
AS
declare @column varchar(1000)
declare @columndata varchar(1000)
declare @sql varchar(4000)
declare @xtype tinyint
declare @name sysname
declare @objectId int
declare @objectname sysname
declare @ident int
set nocount on ......

SQLǶÌ××Ó²éѯ


      ʹÓÃ×Ó²éѯµÄÔ­Ôò
      1.Ò»¸ö×Ó²éѯ±ØÐë·ÅÔÚÔ²À¨ºÅÖС£
      2.½«×Ó²éѯ·ÅÔڱȽÏÌõ¼þµÄÓÒ±ßÒÔÔö¼Ó¿É¶ÁÐÔ¡£
      ×Ó²éѯ²»°üº¬ ORDER BY ×Ӿ䡣¶ÔÒ»¸ö SELECT Óï¾äÖ»ÄÜÓÃÒ»¸ö ORDER BY ×Ó¾ä,
&nb ......

SQL Server±í·ÖÇø²Ù×÷Ïê½â

ÄãÊÇ·ñÔÚǧ·½°Ù¼ÆÓÅ»¯SQL Server Êý¾Ý¿âµÄÐÔÄÜ?Èç¹ûÄãµÄÊý¾Ý¿âÖк¬ÓдóÁ¿µÄ±í¸ñ£¬°ÑÕâЩ±í¸ñ·ÖÇø·ÅÈë¶ÀÁ¢µÄÎļþ×é¿ÉÄÜ»áÈÃÄãÊÜÒæ·Ëdz¡£SQL Server 2005ÒýÈëµÄ±í·ÖÇø¼¼Êõ£¬ÈÃÓû§Äܹ»°ÑÊý¾Ý·ÖÉ¢´æ·Åµ½²»Í¬µÄÎïÀí´ÅÅÌÖУ¬Ìá¸ßÕâЩ´ÅÅ̵IJ¢Ðд¦ÀíÐÔÄÜÒÔÓÅ»¯²éѯÐÔÄÜ¡£
¡¡¡¡SQL ServerÊý¾Ý¿â±í·ÖÇø²Ù×÷¹ý³ÌÓÉÈý¸ö²½Öè×é³É£º
¡ ......

ORACLE SQLÓï¾äÓÅ»¯


1£© Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò(Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ÖÐÓÐЧ)£º
ORACLEµÄ½âÎöÆ÷°´ÕÕ´ÓÓÒµ½×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû£¬from×Ó¾äÖÐдÔÚ×îºóµÄ±í(»ù´¡±í driving table)½«±»×îÏÈ´¦Àí£¬ÔÚfrom×Ó¾äÖаüº¬¶à¸ö±íµÄÇé¿öÏÂ,Äã±ØÐëÑ¡Ôñ¼Ç¼ÌõÊý×îÉٵıí×÷Ϊ»ù´¡±í¡£Èç¹ûÓÐ3¸öÒÔÉϵıíÁ¬½Ó²éѯ, ÄǾÍÐèҪѡÔñ½»²æ±í(intersection ......

Ñ­Ðò½¥½ø½²½âSQL²éѯÓï¾ä¸ß¼¶Ó¦Óü¼ÇÉ

Ò»¡¢ ¼òµ¥²éѯ
¼òµ¥µÄTransact-SQL²éѯֻ°üÀ¨Ñ¡ÔñÁÐ±í¡¢from×Ó¾äºÍWHERE×Ӿ䡣ËüÃÇ·Ö±ð˵Ã÷Ëù²éѯÁС¢²éѯµÄ
±í»òÊÓͼ¡¢ÒÔ¼°ËÑË÷Ìõ¼þµÈ¡£
ÀýÈ磬ÏÂÃæµÄÓï¾ä²éѯtesttable±íÖÐÐÕÃûΪ“ÕÅÈý”µÄnickname×ֶκÍemail×ֶΡ£
SELECT nickname,email
from testtable
WHERE name='ÕÅÈý'
 
(Ò») Ñ¡Ôñ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ