Advertisement
Guest User

Untitled

a guest
Dec 16th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. -- G008-Staffwise Center List
  2. select
  3. st.id,
  4. concat(st.first_name, ' ', st.last_name) as staffname,
  5. c.code,
  6. c.name as center_name,
  7. ci.meeting_place,
  8. ci.meetingType,
  9. ct.name,
  10. concat(c2.code, " ", c2.name) as centerChief,
  11. t1.groupCount,
  12. t2.memberCount
  13. from center_info ci
  14. left join staff st ON st.id = ci.meeting_by
  15. inner join client c ON c.id = ci.id
  16. left join center_type ct on ct.id=ci.center_type
  17. left join client c2 on c2.id=ci.c_u_chief_id
  18. left join
  19. (
  20. SELECT COUNT(*) AS groupCount, c.code
  21. FROM member_group
  22. inner join client c on member_group.center_info_id=c.id
  23. GROUP BY center_info_id
  24. ) as t1 on c.code=t1.code
  25. left join
  26. (
  27. SELECT COUNT(*) AS memberCount, c.code
  28. FROM member_information AS mi
  29. INNER JOIN member_group AS mg ON mi.group_id = mg.id
  30. INNER JOIN client c on mg.center_info_id=c.id
  31. WHERE mi.member_status_id = 1
  32. GROUP BY mg.center_info_id
  33. ) as t2 on c.code=t2.code
  34. where ci.organization=${3_Man_Branch} and ci.status=1
  35. order by st.id;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement