one two
------ ---------
id| value mid|first|last
three four
-------- -------------
id|name id|active|integrated
我希望自己出局(得分是一个新的列,我取值的总和):
first|name|score
到目前为止,我有这个:
select a.first, b.name, sum( case when c.value>0 then 1 else 0 end) as score
from two as a
inner join
three as b
on a.mid = b.id
union
one as c