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