select f_calladdr,count(f_calladdr) as i,sum(F_long) as s,name,phone 
from Tab_Phone as t,users as u 
where u.id=t.f_calladdr 
group by f_calladdr,name,phone 
刚测试完这样是好使的,但是为什么在后面加个order by sum(F_long) desc就不好使了呢 
哪位高手知道啊?帮个忙!

解决方案 »

  1.   

    类似这样:
    select t.f_calladdr,count(f_calladdr) as i,sum(t.F_long) as s,u.name,t.phone 
    from Tab_Phone as t,users as u 
    where u.id=t.f_calladdr 
    group by t.f_calladdr,u.name,t.phone
    order by s desc
      

  2.   

    select f_calladdr,count(f_calladdr) as i,sum(F_long) as s,name,phone 
    from Tab_Ph6 as t,users as u  
    where u.id=t.f_calladdr and year(F_Date)='2007'and month(F_Date)='6' and day(F_Date)='7' and F_Long>120 and UserZu between 1 and 5 
    group by f_calladdr,name,phone 
    order by sum(F_long) desc
    这条SQL语句哪里有问题啊
      

  3.   

    select t.f_calladdr,count(f_calladdr) as i,sum(F_long) as s,u.name,u.phone 
    from Tab_Ph6 as t,users as u  
    where u.id=t.f_calladdr and year(t.F_Date)='2007'and month(t.F_Date)='6' 
         and day(t.F_Date)='7' and t.F_Long>120 and u.UserZu between 1 and 5 
    group by t.f_calladdr,u.name,u.phone 
    order by s desc
      

  4.   

    问题解决拉,其实很简单滴,代码如下:
    select * from ( 
    select f_calladdr,count(f_calladdr) as i,sum(F_long) as u,name,phone from tab_phone as t,users as u 
    where u.id=t.f_calladdr and year(F_Date)='2007'and month(F_Date)='6' and day(F_Date)='7'  and F_Long>120 and UserZu between 1 and 5 group by f_calladdr,name,phone
    ) as tab1 
    order by tab1.i
      

  5.   

    不过,也谢谢hxd001_810(寒冬)积极帮忙!