select count(student_id) , rb.b_id , b_fix_amount , b_fix_amount*(count(student_id)) from student_transaction st join people p on p.people_id = st.student_id join receipt r on r.r_id = st.r_id join Receipt_Bill rb on rb.r_id = r.r_id join bill b on b.b_id = rb.b_id where p.o_id = '17' and r_status_code != 'OPEN' group by rb.b_id;