Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT code_name,
- SUM(estrec_sum) as est,
- SUM(hr_sum) as total,
- SUM(case when hr_status='0' then hr_sum ELSE 0 END) as unbill,
- SUM(case when hr_status='1' then hr_sum ELSE 0 END) as bill
- FROM code
- RIGHT JOIN hr ON code_id=hr_code
- RIGHT JOIN estrec ON code_id=estrec_code
- WHERE hr_job='1' AND estrec_job='1'
- GROUP BY code_name
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement