MySQL Forums
Forum List  »  Newbie

Re: left join on same table use different "where" clause
Posted by: Peter Brawley
Date: February 10, 2013 07:28PM

Is this what you mean?

select contractor,n as jobs,completed,round(100*completed/n,2) as Pct
from (
  select contractor,sum(if(status='completed',1,0) as completed,count(*) as n
  from tbl
  where year(reportdate)=2012
  group by contractor;
) x;

Options: ReplyQuote


Subject
Written By
Posted
Re: left join on same table use different "where" clause
February 10, 2013 07:28PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.