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

SQL Server 2005ÖеÄT SQLÔöÇ¿C

ͨÓñí±í´ïʽ Common Table Expressions
ͨÓñí±í´ïʽ£¨CTE£©ÊÇÒ»¸ö¿ÉÒÔÓɶ¨ÒåÓï¾äÒýÓõÄÁÙʱ±íÃüÃûµÄ½á¹û¼¯¡£ÔÚËûÃǵļòµ¥ÐÎʽÖУ¬Äú¿ÉÒÔ½«CTEÊÓΪÀàËÆÓÚÊÓͼºÍÅÉÉú±í»ìºÏ¹¦ÄܵĸĽø°æ±¾¡£ÔÚ²éѯµÄfrom×Ó¾äÖÐÒýÓÃCTEµÄ·½Ê½ÀàËÆÓÚÒýÓÃÅÉÉú±íºÍÊÓͼµÄ·½Ê½¡£Ö»Ð붨ÒåCTEÒ»´Î£¬¼´¿ÉÔÚ²éѯÖжà´ÎÒýÓÃËü¡£ÔÚCTEµÄ¶¨ÒåÖУ¬¿ÉÒÔÒýÓÃÔÚͬһÅú´¦ÀíÖж¨ÒåµÄ±äÁ¿¡£µ«ÊÇCTEµÄÕæÕýÍþÁ¦ÔÚÓÚËüÃǵĵݹ鹦ÄÜ£¬¼´CTE¿ÉÒÔ°üº¬¶ÔËüÃÇ×ÔÉíµÄÒýÓá£
ÊÓͼ¡¢ÅÉÉú±íºÍCTEÄÚ²¿µÄ²éѯµÄÒ»°ãÐÎʽ
1¡¢ÊÓͼ
CREATE VIEW <view_name>(<column_aliases>) AS <view_query>
2¡¢ÅÉÉú±í
SELECT * from (<derived_table)query>) AS <dericed_table_alias>(<column_aliases>)
3¡¢CTE
WITH <cte_alias>(<column_aliases>)
AS
{
<cte_query>
)
SELECT * from <cte_alias]>
Ôڹؼü×ÖWITHÖ®ºó£¬ÎªCTEÌṩһ¸ö±ðÃû£¬²¢ÇÒΪËüµÄ½á¹ûÁÐÌṩһ¸ö¿ÉÑ¡µÄ±ðÃûÁÐ±í£»±àдCTEµÄÖ÷Ì壻Ȼºó´ÓÍⲿ²éѯÖÐÒýÓÃËü¡£
with aa(id1,id2 )
as
(select xsrq,count(spbm)
from ecv_saledetail where xsrq>='2010-01-01' and xsrq<='2010-01-10'
group by xsrq)
select * from aa


Ïà¹ØÎĵµ£º

SQL ×óÓÒÁ¬½Ó

 ±¾ÎÄ×ªÔØÓÚ£ºhttp://www.javaeye.com/topic/185385
ѧϰÊý¾Ý¿â²éѯµÄʱºò¶Ô¶à±íÁ¬½Ó²éѯµÄÓÐЩ¸ÅÄ±È½ÏÄ£ºý¡£¶øÁ¬½Ó²éѯÊÇÔÚÊý¾Ý¿â²éѯ²Ù×÷µÄʱºò¿Ï¶¨ÒªÓõ½µÄ¡£¶ÔÓڴ˸ÅÄî
ÎÒÓÃͨË×һЩµÄÓïÑÔºÍÀý×ÓÀ´½øÐн²½â¡£Õâ¸öÀý×ÓÊÇÎÒ½²¿ÎµÄʱºò¾­³£²ÉÓõÄÀý×Ó¡£
Ê×ÏÈÎÒÃÇ×öÁ½ÕÅ±í£ºÔ±¹¤ÐÅÏ¢±íºÍ²¿ÃÅÐÅÏ¢±í£¬ÔÚ´Ë£¬±íµ ......

SQL¶ÁÈ¡EXCEL

Ö±½ÓÔÚSQL²éѯ·ÖÎöÆ÷ÖжÁÈ¡EXCELÎļþÐèҪʹÓõ½OPENDATASOURCE¡£
µ«ÊÇʹÓÃËü֮ǰÐèÒª½øÐÐÅäÖÃһϡ£¼ÇµÃÈçÏÂÅäÖÃÊDZØÐëµÄ£º
1¡¢Ö´ÐÐÕâÁ½¸ö´æ´¢¹ý³Ì£º
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
ËüµÄ×÷Óãº
µÚÒ»¸öÊÇ£ºÊÇ·ñÖ§³Ö¸ß¼¶Ñ¡ ......

ÐÂÊÖÈëÃÅ:SQL server2000°²×°Í¼½â

Microsoft SQL server2000ÓÉһϵÁÐÏ໥Э×÷µÄ×é¼þ¹¹³É¡£ÄÜÂú×ã×î´óµÄWEBÕ¾µãºÍÆóÒµÊý¾Ý´¦Àíϵͳ´æ´¢ºÍ·ÖÎöÊý¾ÝµÄÐèÒª¡£±¾ÎÄ´øÀ´µÄ¾ÍÊÇÔÚwindows»·¾³ÏÂSQL2000µÄ°²×°¹ý³Ì¡£
ϵͳÐèÇó
    ÕâÀïÒÔÆäËĺÏÒ»°æ±¾ÎªÀý£¬ÒÔϰ²×°¹ý³ÌͬÀí¡£Microsoft SQL Server 2000 ¿ÉÔÚÔËÐÐ Intel»ò¼æÈÝµÄ Pentium¡¢Pentium Pr ......

SQL Server Ë÷Òý·ÖÎö

SQL ServerʹÓñê×¼B-Ê÷´æ´¢ÐÅÏ¢¡£
Ë÷ÒýÖмä²ã´ÎÊýÓɱíµÄÐÐÊýºÍË÷ÒýÐеĴóС¾ö¶¨¡£ÈôʹÓÃÒ»¸ö½Ï³¤µÄ¼ü£¨key£©À´´´½¨Ë÷Òý£¬Ò»¸ö·ÖÒ³ÉϾÍÖ»ÄÜÈÝÄɽÏÉÙµÄÌõÄ¿£¬¼´Ê÷µÄ²ã´Î¿ÉÄÜ»áÔö¶à¡£
¶ÔÓÚÈκÎË÷Òý£¨ÎÞÂÛÊǾۼ¯»ò·Ç¾Û¼¯Ë÷Òý£©£¬Ë÷ÒýB-Ê÷µÄÒ¶¼¶½Úµã°üº¬Ë÷ÒýµÄ¼üÖµ£¬²¢¶¼°´ÕÕ¼üµÄ˳ÐòÅÅÁС£¾Û¼¯ºÍ·Ç¾Û¼¯Ë÷ÒýµÄÇø±ðÔÚÓÚÒ¶¼¶½Úµ ......

SQL Server2000Êý¾Ý¿â·ÖÀëÓ븽¼Ó

Èç¹ûÄúÊý¾Ý¿âϵͳ°²×°ÔÚϵͳÅÌ£¨±ÈÈç C ÅÌ£©£¬ÓÉÓÚ C ÅÌÈÝÒ×Êܲ¡¶¾ÇÖº¦£¬ÄúÒ²ÐíÏ£ÍûÄúµÄÊý¾Ý´æ·ÅÔÚ·ÇϵͳÅÌ£¨±ÈÈç D ÅÌ£©£¬Òª×öµÄÕâµãºÜ¼òµ¥£¬Äú²¢²»ÐèÒªÖØ×°Êý¾Ý¿â£¬Ö»Òª°ÑÊý¾Ý“·ÖÀ딣¬È»ºó½«Ïà¹ØÎļþÒÆ¶¯µ½ D Å̵Äij¸öĿ¼£¬½Ó×Å“¸½¼Ó”Êý¾Ý¿â¼´¿É¡£
SQL Server 2000ÔÊÐí·ÖÀëÊý¾Ý¿âµÄÊý¾ÝºÍÊÂÎñÈ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ