Dear All
A Table(a)
name station
A station1
A station2
B station1
C station1
B Table (station1)
name qty
A 10
B 20
select count(*) from station1 group by name
结果:
A 10
B 20
但是
select distinct a.name,count(station1.*) from a left join station on a.name=station.name group by a.name
结果
A 20
B 20
看来是因为 a table name=A 出现两次
如果说用
select distinct a.name,count(station1.*) from a left join station on a.name=station.name where a.name='station1' group by a.name
A 10