我需要有关 ms 访问查询的帮助。我当前的分组依据是在我的结果集中添加额外的行。
目前是这样的:
schoolsName organization city agent total organization_award city_award agent_award
John Boscoe 0 0 2 2 10000
John Boscoe 0 26 0 26 1000
John Boscoe 0 2 2 2 4000 100000
John Boscoe 18 0 0 18 10000
John Boscoe 3 3 0 3 5000 10000
我当前对 ms 访问的 sql 查询是:
SELECT
schools.schoolsName, Count(schools.[organization]) AS organization,
Count(schools.[city]) AS city, Count(schools.[agent]) AS agent,
Count(schools.schoolsName) AS total,
IIf((schools.[organization]) Like 'yes',Sum(schools.[dollaramount]),'') AS organization_award,
IIf((schools.[city]) Like 'yes',Sum(schools.[dollaramount]),'') AS city_award,
IIf((schools.[agent]) Like 'yes',Sum(schools.[dollaramount]),'') AS agent_award
FROM schools
GROUP BY schools.schoolsName, schools.[organization], schools.[city], schools.[agent];
如何更改上述查询以获取此结果集:
schoolsName organization city agent total organization_award city_award agent_award
John Boscoe 21 31 4 51 15000 15000 110000