现在有两个表A,B.表结构是相同的.
表结构为:
+-----------+----------+------+-----+---------+----------------+
| Field     | Type     | Null | Key | Default | Extra          |
+-----------+----------+------+-----+---------+----------------+
| id        | int(11)  |      | PRI | NULL    | auto_increment |
| hotline   | char(30) |      |     |         |                |
| user      | char(20) |      |     |         |                |
| score     | char(30) |      |     |         |                |
+-----------+----------+------+-----+---------+----------------+现在我想求两个表的 score的和 和两个表user的数量.按照hotline分组并按照score和的大小降序排序显示出来.该怎么做呢
请指教..多谢~~~
mysql版本为4.0版本

解决方案 »

  1.   

    try:select a.hotline,count(a.user),sum(a.score) from
    (select hotline,user,score from table1
    union all
    select hotline,user,score from table2)a
    group by a.hotline;
      

  2.   

    执行不了哦.
    mysql 4.0版本的好像不支持嵌套查询
      

  3.   

    select a.hotline,count(a.user)+ count(b.user),sum(a.score) +sum(b.score) 
    from a,b
    where 1=1
    group by a.hotline
      

  4.   

    我搜出来的字段只有一个hotline.但是里面应该有很多个hotline才哦