Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. SELECT code_name,
  2. SUM(estrec_sum) as est,
  3. SUM(hr_sum) as total,
  4. SUM(case when hr_status='0' then hr_sum ELSE 0 END) as unbill,
  5. SUM(case when hr_status='1' then hr_sum ELSE 0 END) as bill
  6. FROM code
  7. RIGHT JOIN hr ON code_id=hr_code
  8. RIGHT JOIN estrec ON code_id=estrec_code
  9. WHERE hr_job='1' AND estrec_job='1'
  10. GROUP BY code_name
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement