´æ»õºËËãÄ£¿éÓë×ÜÕËÄ£¿é¶ÔÕ˲»Æ½

·ÖÏíµ½:

2014-01-07 23:16:39

Ô­Òò·ÖÎö: ±¾ÆڵĴæ»õÃ÷ϸÕËÊÕÈë½ð¶î¡¢·¢³ö½ð¶îÓë×ÜÕ˽跽¡¢´û·½¶ÔÕ˲»Æ½£¬µ÷²¦ÒµÎñÖƵ¥Ã»ÓÐÉèÖÃÖмä¿ÆÄ¿£»Ó¦¸¶Ä£¿éʹÓÿâ´æÉÌÆ·ÖƵ¥¡£
½â¾ö·½°¸:
¨C´æ»õÓë×ÜÕ˶ÔÕËϵͳ²éѯÌõ¼þ
¨C1.1 ´æ»õºËËã²éѯÌõ¼þ£º²éѯ»á¼ÆÆڼ䡢ÒÑÖÆƾ֤µÄÃ÷ϸ¿ÆÄ¿¼´£¨cpzid is not null£©
¨C2.2 ×ÜÕ˲éѯÌõ¼þ£º²éѯ»á¼ÆÆڼ䡢Íⲿƾ֤ϵͳΪia¡¢µÄδ×÷·Ï£¨iflag is null£©¼ÇÕË£¨ibook=1£©

¨C¿ª·¢»Ö¸´½Å±¾
select * from (select md,mc,coutno_id,ino_id from dbo.GL_accvouch where ccode=¡¯1406¡ä and iperiod=5) B
left join(select sum(iainprice) as iainprice,sum(iaoutprice)as iaoutprice,cpzid from ia_subsidiary where imonth=5 and cpzid is not null
group by cpzid ) A
on A.cpzid=B.coutno_id
where isnull(A.iainprice,0)<>md or isnull(A.iaoutprice,0)<>mc
order by coutno_id

¨C´æ»õºËËãÓë×ÜÕ˶ÔÕ˲»Æ½×ܽá
¨C²éѯ´æ»õÃ÷ϸ³öÈë¿âºÏ¼ÆÓëƾ֤Ã÷ϸ½è´û·½ºÏ¼Æ(¿¼Âǵ½¶ÔÕË¿ÆÄ¿´«µ½×ÜÕ˵Äƾ֤¿ÉÄÜ´ÓÆäËûÄ£¿é£¨È磺ӦÊÕ/¸¶Ä£¿é¡¢×ÜÕË£©Éú³É£¬¹ÊÐè´ÓÁ½²½¿¼ÂÇ)
select sum(iAInPrice) as [ÊÕÈë½ð¶îºÏ¼Æ],sum(iAOutPrice) as [·¢³ö½ð¶îºÏ¼Æ] from ia_subsidiary where imonth=5 and cinvhead=¡¯1406¡ä and not cPZID is null ¡ª ºËËãºÏ¼Æ
select sum(md) as [ºËËã½è·½ºÏ¼Æ],sum(mc) as [ºËËã´û·½ºÏ¼Æ] from gl_accvouch where iperiod=5 and ccode=¡¯1406¡ä and coutsysname=¡¯ia¡¯ and ibook = 1 and iflag is null ¡ª ÓɺËËãÖƵ¥µÄ×ÜÕ˺ϼÆ
select sum(md) as [×ÜÕ˽跽],sum(mc) as [×ÜÕË´û·½] from gl_accvouch where iperiod=5 and ccode=¡¯1406¡ä and ibook = 1 and iflag is null ¨C×ÜÕ˺ϼÆ

¨C˵Ã÷Ò»£º¼ÙÈç¡°ºËËãºÏ¼Æ¡±=¡°ÓɺËËãÖƵ¥µÄ×ÜÕ˺ϼơ±£¬¶ø<>¡°×ÜÕ˺ϼơ±Ôò˵Ã÷ÓÐÍⲿģ¿éʹÓá®1406¡¯ÖÆƾ֤£¬¿ÉÒÔͨ¹ýÏÂÃæ½Å±¾
select coutsysname as [Íⲿϵͳģ¿é],coutno_id as [ƾ֤Ë÷ÒýºÅ],ioutperiod as [Íⲿƾ֤ÆÚ¼ä],iperiod as [×ÜÕËÆÚ¼ä],ino_id as [ƾ֤ºÅ],cdigest,ccode,md,mc,ccode_equal from gl_accvouch where coutsysname is null and ccode=¡¯1406¡ä and ibook = 1 and iflag is null ¨C²»ÊǺËËãÉú³ÉµÄƾ֤
select coutsysname,coutno_id,md,mc,* from gl_accvouch where iperiod=5 and ccode=¡¯1406¡ä and ibook = 1 and iflag is null order by coutsysname ¨C²éѯƾ֤À´Ô´
¨CÈç²éѯ³ö1406ÓÐÓ¦¸¶Éú³É£¬ÔòÐ轫ÏÂÃæ²éѯ³öµÄ½è·½/´û·½ºÏ¼Æ·ÅÔÚ¡°ºËËãºÏ¼Æ¡±¶ÔÓ¦½Å±¾µÄ½è·½»õ·½£¬²é¿´Ëã³öµÄÖµÊÇ·ñÓë¡°×ÜÕ˺ϼơ±Ò»Ö£¨Èç²»Ò»Ö£¬ËµÃ÷ÎÒµÄÀíÂÛÓÐÎÊÌ⡣Ŀǰ»¹Î´·¢ÏÖ£©
select sum(md),sum(mc) from gl_accvouch where iperiod=5 and ccode=¡¯1405¡ä and coutsysname=¡¯ap¡¯ and ibook = 1 and iflag is null ¨CÓ¦¸¶ÖƵ¥½è´û·½ºÏ¼Æ

¨C˵Ã÷¶þ£º¼ÙÈç¡°ºËËãºÏ¼Æ¡±<>¡°ÓɺËËãÖƵ¥µÄ×ÜÕ˺ϼơ±£¬Ôò˵Ã÷´æ»õºËËãÖƵ¥·Ö¼¼´í£¨Èçµ÷²¦ÒµÎñ£©¡¢»òÕßƾ֤½ð¶îÊÖ¹¤ÐÞ¸Ä
¨C´ËʱÐèÒª±È½Ï½è·½¡¢´û·½ÎªÊ²Ã´²»¶Ô£¬¿ÉÒÔͨ¹ýÒÔϱ¿×¾µÄ·½Ê½²éѯ
¨C2.1 ²éѯ´æ»õÃ÷ϸÊÕÈë½ð¶î¸³Óè±ía ×ÜÕËÃ÷ϸ±í½è·½½ð¶î¼Ç¼¸³Óè±íb
select sum(iAInPrice) as iAInPrice,cpzid into a from ia_subsidiary where imonth=5 and cinvhead=¡¯1406¡ä and not cPZID is null and not iainprice is null group by cpzid
select ino_id,sum(md) as md,coutno_id into b from gl_accvouch where iperiod=5 and ccode=¡¯1406¡ä and coutsysname=¡¯ia¡¯ and ibook = 1 and iflag is null and md<>0 group by ino_id,coutno_id
¨C2.2 ²éѯ´æ»õÃ÷ϸ·¢³ö½ð¶î¸³Óè±íc ×ÜÕËÃ÷ϸ±í´û·½½ð¶î¼Ç¼¸³Óè±íd
select sum(iAOutPrice) as iAOutPrice,cpzid into c from ia_subsidiary where imonth=5 and cinvhead=¡¯1406¡ä and not cPZID is null and not iAOutPrice is null group by cpzid
select ino_id,sum(mc) as mc,coutno_id into d from gl_accvouch where iperiod=5 and ccode=¡¯1406¡ä and coutsysname=¡¯ia¡¯ and ibook = 1 and iflag is null and mc<>0 group by ino_id,coutno_id
¨C2.1.1 ²éѯ³öÊÕÈë´íÎóµÄƾ֤ºÅ
select * from b where coutno_id not in (select cpzid from a) or
coutno_id in (select cpzid from a inner join b on a.cpzid=b.coutno_id where a.iainprice<>b.md)
¨C2.2.1²éѯ³ö·¢³ö´íÎóµÄƾ֤ºÅ
select * from d where coutno_id not in (select cpzid from c) or
coutno_id in (select c.cpzid from c inner join d on c.cpzid=d.coutno_id where c.iaoutprice<>d.mc)
¨C¼ÆËã³ö¡°ºËËãºÏ¼Æ¡±=¡°ÓɺËËãÖƵ¥µÄ×ÜÕ˺ϼơ±¼´¿É
¨C²éѯ¶ÔÓ¦µÄ´æ»õÃ÷ϸ
select sum(iainprice) as [ÊÕÈë½ð¶îºÏ¼Æ],sum(iaoutprice) as [·¢³ö½ð¶îºÏ¼Æ] from ia_subsidiary
where cpzid in (¡¯2012IA0000000001096¡ä)
select cbustype as [ÒµÎñÀàÐÍ],cvoucode as [µ¥¾ÝºÅ],cwhcode as [²Ö¿â±àÂë],cinvcode as [´æ»õ±àÂë],iainprice as [ÊÕÈë½ð¶î],iaoutprice as [·¢³ö½ð¶î],* from ia_subsidiary
where cpzid in (¡¯2012IA0000000001096¡ä)

¨Cɾ³ýÁÙʱ±í
¨Cdrop table a drop table b drop table c drop table d

Õ˶ÔÕ˵ŦÄÜʱ³öÏÖ´æ»õºËËãÄ£¿éÓë×ÜÕËÄ£¿é¶ÔÕ˲»Æ½µÄÏÖÏó£¬ÓÃÓÑ֪ʶ¿â·ÖÎöÖ÷ÒªÔ­ÒòÈçÏ£º

´æ»õϵͳÖеÄÓë×ÜÕ˶ÔÕË»·½Ú£¬¾­³£·¢ÏÖ´æ»õϵͳµÄÆÚ³õ/ÊÕ·¢´æÓë×ÜÕ˵ÄÆÚ³õ/ÊÕ·¢´æÊý¾Ý²»Ò»Ö¡£ ´æ»õÓë×ÜÕ˶ÔÕ˲»Æ½£¬´æ»õϵͳÊǵ¥¾Ý¼ÇÍêÕ˵ÄÊý¾Ý£¬×ÜÕËÊÇƾ֤¼ÇÕËÍêµÄÊý¾Ý£¬¹é¼¯ÆðÀ´³£¼ûµÄÓУº

1¡¢Ç°ÆÚÔ·ݾÍÒѶÔÕ˲»Æ½£¬µ¼ÖºóÆÚÔ·ÝÒ²²»Æ½

2¡¢´æ»õÆÚ³õÓà¶îδָ¶¨¿ÆÄ¿

3¡¢´æ»õϵͳ¼ÇÍêÕË£¬µ«µ±ÔÂδÉú³Éƾ֤

4¡¢×ÜÕ˵Ĵæ»õÀà¿ÆÄ¿³ýÁË´æ»õϵͳ´«µÝÍ⣬×ÔÉí»òÆäËüϵͳҲ»áʹÓôæ»õÀà¿ÆÄ¿

5¡¢´æ»õϵͳÀïµÄµ¥¾Ý¼Ç¼¶ªÊ§Æ¾Ö¤Ë÷ÒýºÅ

6¡¢ÓÉËÄÉáÎåÈëÓÐβ²îµ¼Ö¶ÔÕ˲»Æ½ÈçͼÀýʾ£º

¡¾½â¾ö·½·¨¡¿


 
1¡¢ÓÉÓÚÓë×ÜÕ˶ÔÕ˱íÊÇÑ­»·¹ö¶¯±í£¬¼´ÉϸöÔµÄÆÚĩΪϸöÔµÄÆÚ³õ£¬Òò´ËÈôµ±Ô¶ÔÕ˲»Æ½£¬Ò»¶¨Òª¼ì²éÒÔÇ°Ô·ÝÊÇ·ñÒ»Ö£¬·ñÔòÎÞ·¨³¹µ×½â¾ö´ËÎÊÌâ¡£
2¡¢´æ»õÆÚ³õÒ»¶¨Òª¹Ò´æ»õÀà¿ÆÄ¿£¬·ñÔòÓë×ÜÕ˶ÔÕ˲»Æ½£¬ÈôÊǵ±Ô£¬Ôò»Ö¸´¼ÇÕË£¬¶ÔÆÚ³õ²¹Â¼¿ÆÄ¿£¬ÈôÊÇÒÔÇ°Ô·ݣ¬ÔòÐÞ¸ÄIA_Subsidiary±íµÄCINVHEAD×ֶΡ£
3¡¢ÔÚ´æ»õϵͳ/²ÆÎñºËËã/Éú³Éƾ֤£¬¼ì²éÊÇ·ñÓÐÒÅ©µÄµ¥¾ÝδÉú³Éƾ֤¡£
4¡¢ÔÚ×ÜÕËϵͳ²éѯƾ֤£¬¼ì²éÓÐÎÞÀ´Ô´³ý´æ»õϵͳÍâ´«µÝµÄ´æ»õÀà¿ÆĿƾ֤»ò×ÜÕ˱¾ÉíʹÓùý´æ»õÀà¿ÆÄ¿£¬ÈôÓУ¬ÔòÐèÌÞ³ý´Ë²¿·ÝÊý¾Ý¡£
5¡¢ÔÚgl_accvouch±íÖвéѯ³öƾ֤£¬ÕÒµ½ÏßË÷ºÅ£¬ÔÙ´ò¿ªia_subsidiary½«Æ¾Ö¤ÏßË÷ºÅÌí¼Óµ½cpz_id£¬¶ÔÕËÕý³£¡£
6¡¢ÓÉËÄÉáÎåÈëµ¼Ö´æ»õÓë×ÜÕËÏà²î¼¸·ÖÇ®£¬½¨Òéµ÷ÕûСÊýλλÊýµÄ¾«È·¶È¡£


ÉùÃ÷£º´ËƪΪÓÃÓÑ·þÎñÖÐÐÄÎÄÕ£¬×ªÔØÇë±êÃ÷³ö´¦Á´½Ó£º
  • Ïà¹ØÎÄÕÂ
  • ÈÈÃÅÏÂÔØ
  • Êý¾ÝÐÞ¸´
  • ÈÈÃűêÇ©

Ïà¹ØÀ¸Ä¿

×îÐÂÎÄÕÂ

ÍƼö²úÆ·

Ïà¹ØÎÄÕÂÍƼö

ºÏ×÷»ï°é