Guest User

Untitled

a guest
Mar 16th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. select s.id, s.name, s.address, s.staff_amount, count(d.id) departments_count, sum(d.staff_amount) department_staff, sq.items_count, sq.max_price  from app_shop s inner join app_department d on s.id = d.shop_id inner join (select s.id, count(i.id) items_count, max(i.price) max_price from app_shop s inner join app_department d on s.id = d.shop_id inner join app_item i on d.id = i.department_id group by s.id) sq on s.id = sq.id group by s.id, s.name, s.address, s.staff_amount, sq.items_count, sq.max_price order by s.id;
Advertisement
Add Comment
Please, Sign In to add comment