Êý¾Ý¿âÔ­ÀíÓëÓ¦ÓÃ-ÆÚÄ©¿¼ÊÔ¸´Ï°Ìâ(1)(1)

where dj between 100000 and 200000 7£®²éѯÏúÁ¿¸ßÓÚÆ½¾ùÏúÁ¿µÄÆû³µÃû³Æ select cxmc from QCXX x,JYJL j

where x.qcbh=j.qcbh and xl>(select avg(xl) from JYJL) 8£®²éѯûÓÐÂô³ö¹ýµÄÆû³µ±àºÅ¡£ select qcbh from QCXX

where not in(select qcbh from JYJL); 9£®Ê¹ÓÃSQLÓï¾ä½«Æû³µµ¥¼ÛÔö¼Ó10%¡£ update QCXX set dj=dj*1.1

10£®Ê¹ÓÃSQLÓï¾ä´´½¨Ò»¸öÃûΪzxxl£¨×îÐÂÏúÁ¿£©µÄÊÓͼ£¬ÒªÇóÄܹ»Ê¹ÓøÃÊÓͼ²éѯ2015ÄêÏúÊÛÁ¿µÄ³µÐÍÃû³Æ¡¢µ¥¼Û¡¢ÏúÁ¿ºÍÏúÊÛÈÕÆÚ¡£

create view zxxl as

select cxmc,dj,xl,xsrq from QCXX q,JYJL j where q.qcbh=j.qcbh and xsrq='2015' £¨Æß£©Éè¡°Ö°¹¤_ÉçÍÅ¡±Êý¾Ý¿âÓÐ3¸ö»ù±¾±í£º

Ö°¹¤£ºzg (zgh£¬xm£¬nl£¬xb£¬gz)£» Éç»áÍÅÌ壺shtt(bh£¬nc£¬fzr£¬dd)£» ²Î¼Ó£ºcj(zgh£¬bh£¬rq)¡£

ÆäÖУº£¨1£©Ö°¹¤±ízgµÄÖ÷ÂëΪzgh(Ö°¹¤ºÅ)¡£xmΪÐÕÃû£¬nlΪÄêÁ䣬xbΪÐÔ±ð£¬gzΪ¹¤×Ê¡£

£¨2£©Éç»áÍÅÌå±íshttµÄÖ÷ÂëΪbh£¨±àºÅ£©£¬fzr£¨¸ºÔðÈË£©ÎªÍâÂ룬²ÎÕÕÖ°¹¤±ízgµÄzgh¡£ncΪÃû³Æ£¬fzrΪ¸ºÔðÈË£¬ddΪ»î¶¯µØµã

£¨3£©²Î¼Ó±ícjµÄÖ°¹¤ºÅzghºÍ±àºÅbhΪÖ÷Â룻zghΪÍâÂ룬²ÎÕÕÖ°¹¤±ízgµÄzgh£»±àºÅbhΪÍâÂ룬²ÎÕÕÉç»áÍÅÌå±íshttµÄbh¡£ rqΪ²Î¼ÓÈÕÆÚ¡£

ʹÓÃSQLÓï¾äÍê³ÉÏÂÁвÙ×÷£º

1.¶¨Òå²Î¼Ó±í£¬ÔÚÓï¾äÖÐÒªÇó¶¨Òå±íÖеÄÖ÷ÂëºÍÍâÂëÔ¼Êø£»(˵Ã÷£º±íÖÐÊôÐÔµÄÀàÐ͸ù¾Ýʵ¼ÊÇé¿ö¶¨Òå¡£)

create table cj( zgh char(5), bh char(4), primary key(zgh,bh),

foreign key(zgh) references zg(zgh), foreign key(bh) references shtt(bh))

2.²éѯÿ¸öÉç»áÍÅÌåµÄ²Î¼ÓÈËÊý£» select count(*) from cj group by bh

3.¼ìË÷ËùÓбȡ°Íõ»ª¡±ÄêÁä´óµÄÖ°¹¤µÄÐÕÃû¡¢ÄêÁäºÍÐԱ𣻠select xm,nl,xb from zg

where nl>(select nl from zg where xm='Íõ»ª')

4.²éÕҲμÓÁ˸質¶Ó»òÀºÇò¶ÓµÄÖ°¹¤ºÅºÍÐÕÃû£» select zgh,xm from zg,shtt,cj

where zg.zgh=cj.zgh and shtt.bh=cj.bh and mc in('ÀºÇò¶Ó','¸è³ª¶Ó');

5.²éÕÒûÓвμÓÈκÎÉç»áÍÅÌåµÄÖ°¹¤ÐÅÏ¢£»

selec * from zg where not in(select distinct zgh from cj)

6.½«ËùÓвμӱàºÅΪ¡°10001¡±µÄÉç»áÍÅÌåµÄÖ°¹¤µÄ¹¤×ÊÔö¼Ó10%£» update zg set gz=gz*1.1

where zgh in(select zgh from cj where bh='10001' ) 7.²éѯÄêÁä×î´óµÄÖ°¹¤µÄÖ°¹¤ºÅºÍÐÕÃû£» select zgh,xm from zg where nl=(select max(nl) from zg)

8.²éѯ¸÷Éç»áÍÅÌåµÄ±àºÅÒÔ¼°Æä¸ºÔðÈ˵ÄÐÕÃû£» select bh,xm from zg,shtt where zg.zgh=shtt.fzr

9.ɾ³ýÖ°¹¤ºÅΪ¡¯402¡¯µÄÖ°¹¤²Î¼ÓËùÓÐÉç»áÍÅÌåµÄ¼Ç¼£» delete from cj where zgh='402'

10.ÒÔÖ°¹¤ÐÕÃûΪ²ÎÊý½¨Á¢Ò»¸ö´ø²ÎÊýµÄ´æ´¢¹ý³Ì£¬ÓÃÓÚ²éѯÆäËù²Î¼ÓµÄÉç»áÍÅÌåµÄ±àºÅºÍÃû³Æ£¬²¢µ÷Óô˴洢¹ý³Ì²éѯ¡°ÍõÃ÷¡±Ëù²Î¼ÓµÄÉç»áÍÅÌåµÄ±àºÅºÍÃû³Æ¡£

create procedure procl @name char(8) as

select shtt.bh,mc from zg z,shtt s,cj c

where z.zgh=c.zgh and shtt.bh=c.bh and xm=@name exec procl @name='ÍõÃ÷'

ÁªÏµ¿Í·þ£º779662525#qq.com(#Ìæ»»Îª@)