日期:2014-05-17  浏览次数:20656 次

求一数据库语句,在线等。
现在,在同一张表里面有两个字段。
如下:

表名test
id name  

1 A

2 B

3 A

4 C

5 A
select name as name,count(*) as id from test where id='1' group by name

select name as name,count(*) as id from test where id>'3' group by name

就会有两个结果,我希望,能把这两句话组合,变成结果为:

name ida ida

 A 1 2



 

------解决方案--------------------
SQL code

select * from 
    (select name as name,count(*) as id from test where id='1' group by name) tb1,
    (select name as name,count(*) as id from test where id>'3' group by name)) tb2
where tb1.name = tb2.name;