SELECT "region", sum("items"), sum("actcost")
FROM "apr","Regions"
WHERE "bnfname" LIKE 'Flucloxacillin %' AND apr.sha=Regions.sha
GROUP BY "region"
发出以下错误:
错误:缺少表“region”的FROM子句条目
答案 0 :(得分:1)
试试这个:
SELECT "region", sum("items"), sum("actcost")
FROM "apr","Regions"
WHERE "bnfname" LIKE 'Flucloxacillin %' AND "apr"."sha"="Regions"."sha"
GROUP BY "region"
答案 1 :(得分:0)
SELECT apr.region,
SUM(apr.items),
SUM(apr.actcost)
FROM apr,
Regions
WHERE apr.bnfname LIKE 'Flucloxacillin %'
AND apr.sha = regions.sha
GROUP BY apr.region
或使用加入
SELECT apr.region,
SUM(apr.items),
SUM(apr.actcost)
FROM apr
join regions
ON apr.sha = regions.sha
WHERE apr.bnfname LIKE 'Flucloxacillin %'
GROUP BY apr.region