ms access - Unable to Group on MSAccess SQL multiple search query -
please can me before go out of mind. i've spent while on , resorted asking helpful wonderful people. have search query:
select groups.groupid, groups.groupname, ( select sum(siterates.sitemonthlysalesvalue) siterates invoicesites.siteid = siterates.siteid ) sumofsiterates, ( select count(invoicesites.siteid) invoicesites siterates.siteid = invoicesites.siteid ) countofsites (invoicesites inner join (groups inner join sitesandgroups on groups.groupid = sitesandgroups.groupid ) on invoicesites.siteid = sitesandgroups.siteid) inner join siterates on invoicesites.siteid = siterates.siteid group groups.groupid
with following table relationship
http://m-ls.co.uk/extfiles/sql-relationship.jpg
without group entry can list of entries want drills results down siteid instead want group groupid. know possible lack expertise complete this.
any massively appreciated.
i think need add groups.name
group by
clause, adopt different approach , try avoid subqueries if possible. since have joined required tables can use normal aggregate functions:
select groups.groupid, groups.groupname, sum(siterates.sitemonthlysalesvalue) sumofsiterates, count(invoicesites.siteid) countofsites (invoicesites inner join (groups inner join sitesandgroups on groups.groupid = sitesandgroups.groupid ) on invoicesites.siteid = sitesandgroups.siteid) inner join siterates on invoicesites.siteid = siterates.siteid group groups.groupid, groups.groupname;
Comments
Post a Comment