ËÄܸæËßÎÒ order by ºÍ group by µÄ¾ßÌåÓ÷¨ÒÔ¼°Çø±ð£¬ÖØÔÚÇø±ð£¬×îºÃ¸½ÉÏÒ»¸ö»òÕß¼¸¸öÀý×Ó........... лл£¡ GROUP BY ÊÇ·Ö組£¬ÓÃ來¼Ó總計ËãµÈ²Ù×÷¡£ ORDER BY ¾ÍÊÇÅÅÁÐ順ÐòÓ㬷½±ã²Ù×÷Õ߲鿴數據¡£
ѧϰ SQL code: ²»ºÃ½âÊÍ£¬¿´Àý×Ó
create table tb (id int,counts int)
insert tb select 1,10 union all select 2,40 union all select 3,30 union all select 2,20
--ÔÚûÓÐorder byµÄÇé¿ö select id,counts from tb /* id counts ----------- ----------- 1 10 2 40 3 30 2 20
select o_customer,o_price from orders having o_price >=avg(o_price) select o_customer,o_price from orders where o_price >=(select avg(o_price) from orders) ÎҸоõûÓÐÇø±ð°¡£¬ÔõôÔÚmysql»áÓÐ ......