2016-07-25 7 views
1

私は、ケースの合計と通過したケースのリストを取得しようとしています。ここに私が書いた質問があります。LEFT JOINエラーがワークベンチで

select totalcases.feature,passedcases.passed,totalcases.total 

from ((select feature, count(distinct templateid) as Total 
     from results 
     where build = 'random' group by feature 
     ) AS totalcases) 
LEFT JOIN ((select feature,count(distinct templateid) as PASSED 
      from results 
      where build='random' and result='PASS' group by feature 
     ) AS passedcases) using feature; 

mysqlには構文エラーがあります。また、ワークベンチでは、端末のような異なる行でクエリを壊すことはできませんか?

答えて

1

おそらく

select feature, 
      sum(case when result = 'PASS' then 1 else 0 end) as passed, 
      count(*) as totalcases 
from  results 
where  build = 'random' 
group  by feature 
order  by feature 
+0

スウィートでグループを使用してはるかに単純行うことができます!ありがとう。これは私に多くのものをクリアします。 –