2014-03-06 142 views

回答

1

嘗試這種情況:

SELECT AVG(FieldA) as Average FROM Table1 
WHERE FieldB='a' 

其結果將是:

AVERAGE 
308 

中看到結果SQL Fiddle

AVG()返回值的平均值在一組。空值被忽略。

語法:

AVG ([ ALL | DISTINCT ] expression) 

瞭解更多關於AVG()here

1

嘗試this.You可以使用AVG

SELECT AVG(FieldA) AS Average 
FROM tablename 
WHERE FieldB='a' 

SQL FIDDLE

enter image description here

0

嘗試這樣

SELECT Avg(FieldA) AS Average 
FROM Table1 
WHERE FieldB = 'a' 
0
select avg(fieldA) 
from table_name 
where fieldB='a'; 

fiddle