【发布时间】:2017-06-21 03:59:36
【问题描述】:
我正在尝试选择特定位置的平均分数进行比较 目的。使用语句
SELECT l.location_name AS "Location Of Store",
AVG (f.score) AS "Average Score"
FROM feedback AS f
JOIN employee AS e
ON f.qr_id = e.qr_id
JOIN location AS l
ON e.location_id = l.location_id
WHERE e.company_id = '1'
+ ----------------- + ------------- +
| Location of Store | Average Score |
+ ----------------- + ------------- +
| London | 5.3333 |
+ ----------------- + ------------- +
如果我降低平均水平
SELECT l.location_name AS "Location Of Store",
f.score AS "Average Score"
FROM feedback AS f
JOIN employee AS e
ON f.qr_id = e.qr_id
JOIN location AS l
ON e.location_id = l.location_id
WHERE e.company_id = '1'
Then the results I want to see however this isn't the average score
+ ----------------- + ------------- +
| Location of Store | Average Score |
+ ----------------- + ------------- +
| London | 9 |
| Bedfordshire | 2 |
| Buckinghamshire | 5 |
+ ----------------- + ------------- +
可能错过了一些简单的东西,我不能指望它!
【问题讨论】:
标签: mysql sql sql-server phpmyadmin