SQL²éѯÅÅÐÐ
SQL code:
sql="select name,channelid from model_channel where channelid in (select rootchannel from model_content group by rootchannel order by sum(hits) desc) and rootchannel=81"
ACCESSÊý¾Ý¿â.Ϊʲô¶Á²»µ½Öµ?·µ»Ø¿Õ¼Ç¼¼¯.
ÎÒÖ±½ÓÔËÐÐselect rootchannel from model_content group by rootchannel order by sum(hits) descʱËüµ¯³öÒ»¸ö´°¿Ú.ÌáʾÎÒÊäÈë²ÎÊýrootchannel
ÊäÈëÁËrootchannel¾ÍÄܲé³öÀ´.²»ÊäÈë¾Í²»Äܲéѯ.
rootchannelÊǸù²Ëµ¥µÄID.
ACCESS °ï¶¥..
select name,channelid
from model_channel
where channelid
in (select rootchannel from model_content group by rootchannel)
-- order by sum(hits) desc)
and rootchannel=81
×Ó¾äÀïÃæÒªÓÃORDER BY µÄ,Ò»°ãÒª¼ÓTOP N·ñÔòÓ¦¸Ã»á±¨´íµÄ
access µÄ½¨Òéת°æ,°ï¶¥.
sql="select a.name,a.channelid
from model_channel a, model_content b
where a.channelid =b.rootchannel and a.rootchannel=81"
select name,channelid
from model_channel
where channelid in
(select rootchannel from model_content group by rootchannel order by sum(hits) desc)
and rootchannel=81
Ïë²»³öÄãÕâÀïµÄÅÅÐòÓÐʲôÒâÒå
¶÷.×Ô¼º½â¾öÁË.д´íÁËÒ»¸ö×Ö¶Î.µ¼Ö³ö´í..лл¸÷λ..
Ïà¹ØÎÊ´ð£º
Ö´ÐеÄ˳Ðò£º
1£©Îļþä¯ÀÀ¿ò£¨Ñ¡ÔñÎļþʹÓã©
Ñ¡ÔñºÃÎļþºó
µã»÷Ò»¸öµ¼Èë°´Å¥µÄʱºò £¬°ÑÉÏÃæÉÏ´«¿òÀïµÄcsvÎļþÒÔÒ»¸öIDΪÎļþÃû£¬ÉÏ´«µ½**/**Îļþ¼ÐÏÂ
2£©¶ÁÈ¡Õâ¸öÎļþ¼ÐϵÄcsvµÄÎļþ£¬×ª»»³Ésql
3 ......
СµÜ£¬×î½üҪתÐÐÈ¥×öoracle¿ª·¢ÁË£¬ÓÉÓÚ´óѧ±Ïҵʱ£¬×ßÁ˸öÍä·£¬ÏÖÔÚºÜСÐÄ£¬ÎÊÏ£¬×öPL/SQLÓÐûÓÐǰ;£¿£¿£¿
µ±È»ÎÒ˵µÄÕâ¸öǰ;ÊÇÖ¸ ÒÔºóÒªÌø²Û£¬Êг¡¶ÔÕâÑùµÄÈ˲ŵÄÐèÇóÁ¿´ó²»´ó£¿£¿
3q ÄÇ¿´À´»¹Ö»ÄÜÏȽӴ ......
ÈçºÎÔÚSQL2005ÖÐÉ趨¶¨Ê±×÷Òµ£¬±ÈÈç˵¶¨Ê±ÇåÀíijЩ±íµÄÊý¾Ý£¬
»òÕßÊǶ¨Ê±µÄ½«Ä³Ð©±íµÄÊý¾Ýµ¼³öexcel£¡
ÔÚÏߵȴý£¬¼±¼±¼±£¬×îºÃÊÇÏêϸ²½Ö裡
֮ǰÎÒ×öµÄ×÷ÒµÓеãÎÊÌ⣡
°ïUP
²Î¿¼:http://hi.baidu.com/toiota ......
1¡£ÔõÑùʹxp_cmdshellÄÜÍêÕûÊä³ö³¬¹ý255¸ö×Ö·ûµÄ×Ö·û´®¡£
2¡£select ʱ£¬¼ìË÷ËÙ¶ÈÊÇÓëfromºóµÄ TABLE˳ÐòÓйأ¬»¹ÊÇÓëwhereÌõ¼þµÄ˳ÐòÓйØ(TABLEÊý¾Ý¶àÉÙ )
ÔÚϵͳÊôÐÔÉ趨ÀïÓиöÑ¡Ïî,¿ÉÒÔÐ޸ĵ¥×Ö¶ÎÊä³ö×ÖÊýÏÞÖÆ. ......
1.Ôõô°ÑÊý¾Ý´ÓsqlserverÀïÃæµÄÊý¾ÝдÈëµ½Ö¸¶¨Â·¾¶µÄexcel
±ÈÈç
declare @¹«Ë¾Ãû³Æ char(50)
set @¹«Ë¾Ãû³Æ = (select ¹«Ë¾Ãû³Æ from ¹«Ë¾ÐÅÏ¢)
EXEC [master]..xp_cmdshell 'bcp "select * from [master]. ......