ÇósqlÓï¾ä
ÓÐÈýÕűí·Ö±ðÈçÏ£º header£¨id£¬state£©£¨idΪÖ÷¼ü£© 1,0 2,1 3,0 detail(id£¬headerid£¬unsendamount£¬bkcataid)£¨headeridΪheader±íµÄÖ÷¼ü£© 1,1,1,2 2,1,1,3 3,2,2,4 4,2,1,5 5,3,5,6 6,3,5,7 store£¨id£¬bkcataid£¬amount£©£¨bkcataidÓëdetail±íµÄbkcataidÏà¶ÔÓ¦£© 1,2,1 2,2,1 3,3,1 4,4,0 5,4,1 6,5,1 7,6,10 ÏÖÔÚÎÒÏë²éѯheader±íµÄid×Ö¶ÎΪ2ºÍ3 ¼´²éѯÌõ¼þΪheader±íµÄstateÊÇ0»òÕß1£¬detail±íµÄunsendamount×ֶδóÓÚ0£¬detail±íbkcataid¶ÔÓ¦unsendamount´óÓÚstore±íbkcataid¶ÔÓ¦µÄamountµÄ×ܺͻòÕßstore±íûÓÐdetail±íÏàÓ¦µÄbkcataid¡£
´ËÌâ°ï¶¥ÁË£¬¿´ÔÎÁËÒýÓà ´ËÌâ°ï¶¥ÁË£¬¿´ÔÎÁË ¿ÉÄÜÊÇÎÒûÓÐÃèÊöÇå³þ°É£¬ÓÐÒ»¸öµ¥Í·±íheaderºÍÒ»¸öÃ÷ϸ±ídetail£¬Ã¿¸öµ¥Í·ÓжàÌõÃ÷ϸ£¬Ã¿ÌõÃ÷ϸÓÐÒ»¸ö·¢»õÎïidΪbkcataidºÍδ·¢»õÊýÁ¿unsendamount£¬»¹ÓÐÒ»¸ö¿â´æ±ístore´æ·ÅÁË·¢»õÎïid£¨bkcataid£©ºÍ¿â´æÊýÁ¿amount£¬ÏÖÔÚÏë²éѯ³öÄÇЩµ¥×ÓµÄ״̬ÔÚ£¨0£¬1£©Ö®ÖУ¬²¢ÇÒÃ÷ϸÀïÃæÎ´·¢»õÊýÁ¿unsendamount´óÓÚ0,ͬʱδ·¢»õÊýÁ¿unsendamount´óÓÚ¿â´æµÄÊýÁ¿¡£ ±»Ìõ¼þ¶¼ÅªÔÎÁË ×îºóÄǾäºÃÈÆ.. SQL code: DECLARE storeAmount int --ÏÈÈ¡µÃstore·ûºÏÌõ¼þµÄamountµÄ×ÜºÍ ,storeÎÞbkcataidʱ Ϊnull,Óм´·µ»ØÒ»¸öÖµ SELECT storeAmount=SUM(store.amount) from detail INNER JOIN store ON detail.bkcataid=store.bkcataid --ÄÚÁ¬½Ó²éѯ SELECT header.* --Òª·
Ïà¹ØÎÊ´ð£º
type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jas ......
×Ö¶Î1,×Ö¶Î2.....×Ö¶ÎN,Status,ParentID 1,Name1....test1,1,99 1,Name1....test1,3,99 1,Name2....test2,1,101 1,Name2....test2,3,101 1,Name3....test3,2,101 1,Name1....test1,4,101 ÏëÒªµÄ½á¹ûÊÇ: 1,Na ......
µÚÒ»¾ä: select ht.gfdm,gfdm.gfmc,gfdm.lb ,sum(jh.htdj*jh.htsl)as je from ht left join gfdm on ht.gfdm=gfdm.gfdm join jh on ht.htbh=jh.hth and ht.htbh not like'del%' and ht. ......
ÇëÎÊ Ìí¼ÓÐÂÊý¾ÝÔ´->Êý¾Ý¿â->Ìí¼ÓÁ¬½Ó Õâ¸ö½çÃæÏ£¬Êý¾ÝÔ´Ñ¡Ôñ£ºMicrosoft SQL Server (SqlClient)£» ·þÎñÆ÷Ãû£º Ó¦¸ÃÐ´Ê²Ã´ÄØ£¿ ÓÐËÖªµÀ£¿¶àл¸÷λ£¡£¡ Äãµ½µ×ÊÇÒªÁ¬mysql»¹ÊÇmssql£¿ ÒýÓà ÇëÎÊ ......