Leon 13 Posted February 6, 2017 Share Posted February 6, 2017 (edited) Update - Nevermind, worked it out HiQuick SQL question... I'm sure this is easy to those in the know!I'm running a quick query against some tables and receiving the following results: Business | Site | Staff Insurance | NCL | Steve Insurance | NCL | Cath Insurance | MAN | Bob Billing | MAN | Sarah Billing | MAN | Tom Complaints | MAN | Andy I want to aggregate this to have the total number of staff rather than the individuals: Billing | MAN | 2 Complaints | MAN | 1 Insurance | MAN | 1 Insurance | NCL | 2 I've got so far with the query but can't work out how to group both the sites and the staff. It only works if I simplify to two columns (Site and staff) select b.name, s.name, count(a.staff_id) from staff a, sites s, business b where b.bu_id = s.bu_id and a.site_id = s.site_id order by b.name, s.name Edited February 6, 2017 by MiddleAgeCool Link to comment Share on other sites More sharing options...
scoobos 298 Posted February 8, 2017 Share Posted February 8, 2017 first rule of internet question asking for geeks - if you "work it out" then update your post with the solution.... I spent 2 mins reading through it ! Link to comment Share on other sites More sharing options...
Rayvin 5222 Posted February 8, 2017 Share Posted February 8, 2017 I'd also be interested in your solution. Link to comment Share on other sites More sharing options...
scoobos 298 Posted February 10, 2017 Share Posted February 10, 2017 Lol that makes 2 of us who've wasted time Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now