¡¶¹ÜÀíÐÅϢϵͳA¡·ÊµÑéÖ¸µ¼ÊéÒ»_Êý¾Ý¿âÓ¦Óà ÏÂÔØ±¾ÎÄ

from sales

group by sale_id

having sum(tot_amt)>40000 order by sum(tot_amt) desc 39¡¢ ÕÒ³ö¹«Ë¾ÄÐÒµÎñÔ±Ëù½ÓÇÒ¶©µ¥½ð¶î³¬¹ý2000ÔªµÄ¶©µ¥ºÅ¼°¶©µ¥½ð¶î¡£ Select order_no,tot_amt

From sales ,employee

Where sale_id=emp_no and sex='M' and tot_amt>2000 40¡¢ ²éѯsales±íÖж©µ¥½ð¶î×î¸ßµÄ¶©µ¥ºÅ¼°¶©µ¥½ð¶î¡£

Select order_no,tot_amt from sales where tot_amt=(select max(tot_amt) from sales) 41¡¢ ²éѯÔÚÿÕŶ©µ¥Öж©¹º½ð¶î³¬¹ý24000ÔªµÄ¿Í»§Ãû¼°ÆäµØÖ·¡£

Select cust_name,addr from customer a,sales b where a.cust_id=b.cust_id and tot_amt>24000

42¡¢ Çó³öÿλ¿Í»§µÄ×ܶ©¹º½ð¶î£¬ÏÔʾ³ö¿Í»§ºÅ¼°×ܶ©¹º½ð¶î£¬²¢°´×ܶ©¹º½ð¶î½µÐòÅÅÁС£ Select cust_id,sum(tot_amt) from sales

Group by cust_id

Order by sum(tot_amt) desc 43¡¢ Çóÿλ¿Í»§¶©¹ºµÄÿÖÖ²úÆ·µÄ×ÜÊýÁ¿¼°Æ½¾ùµ¥¼Û£¬²¢°´¿Í»§ºÅ£¬²úÆ·ºÅ´ÓСµ½´óÅÅÁС£ Select cust_id,prod_id,sum(qty),sum(qty*unit_price)/sum(qty)

From sales a, sale_item b Where a.order_no=b.order_no Group by cust_id,prod_id Order by cust_id,prod_id 44¡¢ ²éѯ¶©¹ºÁËÈýÖÖÒÔÉϲúÆ·µÄ¶©µ¥ºÅ¡£ Select order_no from sale_item

Group by order_no Having count(*)>3 45¡¢ ²éѯ¶©¹ºµÄ²úÆ·ÖÁÉÙ°üº¬Á˶©µ¥10003ÖÐËù¶©¹º²úÆ·µÄ¶©µ¥¡£ Select distinct order_no

From sale_item a

Where order_no<>'10003'and not exists (

Select * from sale_item b where order_no ='10003' and not exists

(select * from sale_item c where c.order_no=a.order_no and c.prod_id=b.prod_id)) 46¡¢ ÔÚsales±íÖвéÕÒ³ö¶©µ¥½ð¶î´óÓÚ¡°E0013ÒµÎñÔ±ÔÚ1996/11/10ÕâÌìËù½ÓÿһÕŶ©µ¥µÄ½ð¶î¡±µÄËùÓж©µ¥£¬²¢ÏÔʾ³Ð½ÓÕâЩ¶©µ¥µÄÒµÎñÔ±ºÍ¸Ã¶©µ¥µÄ½ð¶î¡£ Select sale_id,tot_amt from sales

where tot_amt>all(select tot_amt from sales where sale_id='E0013' and

order_date='1996/11/10') 47¡¢ ²éѯĩ³Ð½ÓÒµÎñµÄÔ±¹¤µÄÐÅÏ¢¡£ Select *

From employee a Where not exists

(select * from sales b where a.emp_no=b.sale_id) 48¡¢ ²éѯÀ´×ÔÉϺ£ÊеĿͻ§µÄÐÕÃû£¬µç»°¡¢¶©µ¥ºÅ¼°¶©µ¥½ð¶î¡£ Select cust_name,tel_no,order_no,tot_amt

From customer a ,sales b

Where a.cust_id=b.cust_id and addr='ÉϺ£ÊÐ' 49¡¢ ²éѯÿλҵÎñÔ±¸÷¸öÔµÄÒµ¼¨£¬²¢°´ÒµÎñÔ±±àºÅ¡¢Ô·ݽµÐòÅÅÐò¡£ Select sale_id,month(order_date), sum(tot_amt) from sales

group by sale_id,month(order_date) order by sale_id,month(order_date) desc 50¡¢ÇóÿÖÖ²úÆ·µÄ×ÜÏúÊÛÊýÁ¿¼°×ÜÏúÊÛ½ð¶î£¬ÒªÇóÏÔʾ³ö²úÆ·±àºÅ¡¢²úÆ·Ãû³Æ£¬×ÜÊýÁ¿¼°×ܽð¶î£¬²¢°´²úÆ·ºÅ´ÓСµ½´óÅÅÁС£

Select a.prod_id,prod_name,sum(qty),sum(qty*unit_price)

From sale_item a,product b Where a.prod_id=b.prod_id Group by a.prod_id,prod_name Order by a.prod_id 51¡¢²éѯ×ܶ©¹º½ð¶î³¬¹ý¡¯C0002¡¯¿Í»§µÄ×ܶ©¹º½ð¶îµÄ¿Í»§ºÅ£¬¿Í»§Ãû¼°Æäסַ¡£ Select cust_id, cust_name,addr

From customer

Where cust_id in (select cust_id from sales Group by cust_id

Having sum(tot_amt)>

(Select sum(tot_amt) from sales where cust_id='C0002')) 52¡¢ ²éѯҵ¼¨×îºÃµÄµÄÒµÎñÔ±ºÅ¡¢ÒµÎñÔ±Ãû¼°Æä×ÜÏúÊÛ½ð¶î¡£

select emp_no,emp_name,sum(tot_amt) from employee a,sales b where a.emp_no=b.sale_id group by emp_no,emp_name having sum(tot_amt)=

(select max(totamt)

from (select sale_id,sum(tot_amt) totamt from sales

group by sale_id) c) 53¡¢ ²éѯÿλ¿Í»§Ëù¶©¹ºµÄÿÖÖ²úÆ·µÄÏêϸÇåµ¥£¬ÒªÇóÏÔʾ³ö¿Í»§ºÅ£¬¿Í»§Ãû£¬²úÆ·ºÅ£¬²úÆ·Ãû£¬ÊýÁ¿¼°µ¥¼Û¡£

select a.cust_id, cust_name,c.prod_id,prod_name,qty, unit_price from customer a,sales b, sale_item c ,product d

where a.cust_id=b.cust_id and b.order_no=c.order_no and c.prod_id=d.prod_id

54¡¢Çó¸÷²¿Ãŵį½¾ùнˮ£¬ÒªÇó°´Æ½¾ùнˮ´ÓСµ½´óÅÅÐò¡£

select dept,avg(salary) from employee group by dept order by avg(salary)

ʵÑ鱨¸æ»ù±¾¸ñʽ

ʵÑéÃû³Æ£º ѧºÅ£º ÐÕÃû£º Ò»¡¢ÊµÑéÄ¿µÄ

¶þ¡¢ÊµÑé»·¾³

Èý¡¢ÊµÑéÄÚÈÝÓë²½Ö裨д³öÿ´ÎʵÑé²½ÖèÒÔ¼°½á¹û£©

ʵÑ鱨¸æÑùÀý£±

ʵÑéËÄ

ʵÑéÃû³Æ£º¼òµ¥²éѯ ѧºÅ£º00200012 ÐÕÃû£ºÀîÃÛ Ò»¡¢ÊµÑéÄ¿µÄ

Àí½âSELECTÓï¾äµÄ²Ù×÷ºÍ»ù±¾Ê¹Ó÷½·¨£¬ÊìÁ·Ê¹ÓÃUPDATE/INSERT/DELETEÓï¾ä½øÐбí²Ù×÷¡£ ¶þ¡¢ÊµÑé»·¾³

ÆÕͨPC»ú£¬MS SQL SERVER 2000Êý¾Ý¿â¡£ Èý¡¢ÊµÑéÄÚÈÝÓë²½Öè 1¡¢ ²éÕÒËùÓо­ÀíµÄÐÕÃû¡¢Ö°³Æ¡¢Ð½Ë®¡£

2¡¢ ²éÕÒ³öÐÕ¡°Íõ¡±²¢ÇÒÐÕÃûµÄ×îºóÒ»¸ö×ÖΪ¡°¹¦¡±µÄÔ±¹¤¡£

3¡¢ Ìí¼ÓÒ»Ìõ¼Ç¼ÖÁemployee±í£¨ÓÃINSERT?..INTO£©¡£

δÌí¼Ó֮ǰ£º

Ìí¼ÓÖ®ºó±ä³ÉÁË21Ìõ¼Ç¼¡£

4¡¢ ½«Ã¿¸öÔ±¹¤µÄнˮÉϵ÷3%¡£

×¢£ºÔ­À´µÄнˮ£º Éϵ÷ºóµÄ½á¹û£º

5¡¢ ²éÕÒסÔÚÉϺ£»ò±±¾©µÄŮԱ¹¤£¬²¢ÏÔʾÆäÐÕÃû¡¢ËùÊô²¿ÃÅ¡¢Ö°³Æ¡¢×¡Ö·¡£

·½·¨Ò»£º

×¢£ºÓÉÓÚûÓб±¾©µÄŮְԱ£¬¹ÊûÓÐÏÔʾ¡£ 6¡¢ ÔÚ±ísalesÖÐÌô³öÏúÊÛ½ð¶î´óÓÚµÈÓÚ10000Ôª¶©µ¥¡£