I have a simple SQL
command:
SELECT Avg('observations1') AS AvgFeedback,
Avg('observations2') AS AvgChallenge,
Avg('observations3') AS AvgTalk,
Avg('observations4') AS AvgSkills,
Avg('observations5') AS AvgExpectations
FROM .observations
WHERE obsschool = 'admin';
However every result is 0 when there are numbers in each of the fields. What am I doing wrong? Thanks.
Remove the quotes ( '
) wrapping your field names:
SELECT Avg(observations1) AS AvgFeedback,
Avg(observations2) AS AvgChallenge,
Avg(observations3) AS AvgTalk,
Avg(observations4) AS AvgSkills,
Avg(observations5) AS AvgExpectations
FROM observations
WHERE obsschool = 'admin';
When passing field names, no quotes necessary.
您可以尝试一下,看看会得到什么结果吗:
avg(cast(observations1 as dec(7,5))) as AvgFeedback
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.