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

group_by·ÖÒ³(Sql Server)

×÷Õߣº°½Ê¿Î°
Ò»ÕÅÓÐgroup byºó¿ÉÄܺܶàÖظ´ÐУ¬ÕâʱÓÃnot inµÈ»ùÓÚΨһÁеķֲ¼Ëã·¨»á´æÔÚÎÊÌâ¡£
ÎҵĽâ¾ö°ì·¨ÊÇ£º
Ò»ÕűíÓÐÒ»¸öid intµÄÖ÷¼ü£¬¶ÔÆäËüÁнøÐÐgroup by£¬·Öҳ˼ÏëÊÇ£º°Ñmax(id)×ögroup byºóµÄΨһÁУ¬»¹ÊÇÓÃnot inµÄ·Ö²¼Ë¼Ïë¡£
Àý£º
select top 4 sum(int_TZ2_id) as id,dt_TZ2_date,vchar_TZ2_PingZheng,vchar_TZ2_ZaiYao,vchar_TZ2_DanSN,convert(decimal(18,4),sum(float_TZ2_J_ShuLiang)) as j_sl, convert(decimal(18,4),sum(money_TZ2_J_JingE)) as j_je,convert(decimal(18,4),sum(float_TZ2_D_ShuLiang)) as d_sl, convert(decimal(18,4),sum(money_TZ2_D_JingE)) as d_je from tbTaiZhang2 
       where 1=1 and 2=2   group by dt_TZ2_date,vchar_TZ2_PingZheng,vchar_TZ2_ZaiYao,vchar_TZ2_DanSN
       having (max(int_TZ2_id) NOT IN
                (SELECT TOP          4 max(int_TZ2_id) as id
               from tbTaiZhang2 
       WHERE 1=1 and 2=2   group by dt_TZ2_date,vchar_TZ2_PingZheng,vchar_TZ2_ZaiYao,vchar_TZ2_DanSN
               ORDER BY dt_TZ2_date,id ASC))
     ORDER BY dt_TZ2_date,id ASC


Ïà¹ØÎĵµ£º

º½¿Õ¹«Ë¾¹ÜÀíϵͳ(VC++ ÓëSQL 2005)

ϵͳ»·¾³£ºWindows 7
Èí¼þ»·¾³£ºVisual C++ 2008 SP1 +SQL Server 2005
±¾´ÎÄ¿µÄ£º±àдһ¸öº½¿Õ¹ÜÀíϵͳ
      ÕâÊÇÊý¾Ý¿â¿Î³ÌÉè¼ÆµÄ³É¹û£¬ËäÈ»³É¼¨²»¼Ñ£¬µ«ÊÇ×÷ΪÎÒÓÃVC++ ÒÔÀ´±àдµÄ×î´ó³ÌÐò»¹ÊÇ´«µ½ÍøÉÏ£¬ÒÔ¹©²Î¿¼¡£ÓÃVC++ ×öÊý¾Ý¿âÉè¼Æ²¢²»ÈÝÒ×£¬µ«Ò²²»ÊDz»¿ÉÄÜ¡£ÒÔÏÂÊÇÎҵijÌÐò½çÃ棬ºóÃæ ......

ÓÃÌæ´ú±äÁ¿µÄ·½Ê½±àдsqlÓï¾ä

SQL> select * from dept where deptno=&tt;
Enter value for tt:20
DEPTNO DNAME          LOC
------ -------------- -------------
    10 ACCOUNTING     NEW YORK
ÕâÑùÎÞÂÛÊäÈë¶àÉÙ´ÎttµÄÖµ£¬ÏµÍ³Ö»½¨Á¢Ò»¸öÖ´Ðмƻ®£¬Ì ......

SQLÓï¾äµ¼Èëµ¼³ö´óÈ«


£¨×¢Òâoffice2007µÄͬѧ°Ñprivider='Microsoft.Jet.OLEDB.4.0'¸ÄΪ'Microsoft.ACE.OLEDB.12.0'¡£¡£offiec2003Óë2007µÄÌṩÆ÷ÊDz»Ò»ÑùµÄ¡£¡££©
 
 
 
 
SQLÓï¾äµ¼Èëµ¼³ö´óÈ«[ÊÕ¼¯]
/******* µ¼³öµ½excel
EXEC master..xp_cmdshell 'bcp SettleDB.dbo.shanghu out c:\temp1.xls -c -q -
S"GNE ......

sqlµãµÎ

×Ó±í²éѯ£¬¸¸±íÒ»¶¨Òª¼Ó±ðÃû£¬·ñÔòÊý¾Ý»áÓÐÎÊÌ⣬²»±¨±àÒë´í
select * from table1 a where exist(select 1 from table2 where a.id=b.id)
´æ´¢¹ý³Ì½á¹û¼¯²åÈëµ½ÏÖÓбí
insert into table1 exec procname args
ÁªºÏÒÑÓÐ±í£¬½ô¸úÔÚºóÃ棬¶Ô»ã×ܺÜÓÐÓÃ
select a from table1 union all select 'ºÏ¼Æ'
½á¹û¼¯ÀïµÄij ......

°²×°|SQL³öÏÖredist.cabºÍsql.cab´íÎó½â¾ö°ì·¨

ÔÚÍøÉÏÏÂÁËÒ»¸ö°æ±¾µÄSQL2008£¬Ò»²½²½°²×°£¬°²×°¹ý³ÌÖÐÓöµ½ÁËredist.cab ºÍSql.cab´íÎ󣬵«»ù±¾¹¦ÄÜ»¹ÊÇÄÜÓ㬵«»¹ÊDz»ÄÜÈÝÈÌ´íÎóµÄ´æÔÚ£¬¾­Ò»·¬ËÑË÷£¬ÖÕÓÚÕÒµ½Á˽â¾ö·½°¸£º
ÏÂÔØmsxml°²×°£¬ÎÒÒ»¿ÚÆø°²×°ÁËmsxml4.0 sp3ºÍmsxml6.0Á½¸öÎļþ
Ϊʲô°²×°Õâ¸ö¶«Î÷ÄÇ?
ÏëÆðÀ´ÁË£¬ÒòΪ°²×°Ê±±¨µÄ´íÎóÊÇÓëÍøÂçÓйØϵ£¬¶øÎÒµÄwin ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ