sqlserver平均数,平均值 sql
怎么在SQLServer计算列和平均值
select sum(求和栏位),sum(求和栏位)/count(*) --总和,平均值
网站建设哪家好,找创新互联建站!专注于网页设计、网站建设、微信开发、微信平台小程序开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了富顺免费建站欢迎大家使用!
from 表名
SQLserver中三个表的查询,去重复与计算平均值
select t1. mingchen,avg(t2.fenshu)
from zhibiao as t1
inner join pingjia_xuanxian as t2
on t1.id=t2.id
group by t1.mingchen
sqlServer 查询各小时的平均值
select convert(varchar,time,23),datepart(hh,time),avg(valueavg),max(valueavg)
from tb group by convert(varchar,time,23),datepart(hh,time)
怎么用sql语句编写求平均值的问题
SELECT 省, 市, 县, year(日期) 年份, AVG(ABS(闪电强度)) 闪电强度绝对值的平均值
FROM HUBEISHENG
GROUP BY 省, 市, 县,year(日期)
关于用sql语句求平均值,就是把一个表中的所有字段按时间字段的小时来求平均值,而不是按时间段求
--已出结果 SQLSERVER2000
--生成测试数据
CREATE TABLE TestA
(
a int,
b int,
c int,
time datetime
)
INSERT INTO TestA
SELECT 12,13,45,'2009-6-9 10:59:26'
UNION ALL
SELECT 11,41,43,'2009-6-9 10:59:30'
UNION ALL
SELECT 10,75,742,'2009-6-9 11:00:40'
UNION ALL
SELECT 78,72,56,'2009-6-9 11:30:50'
UNION ALL
SELECT 52,11,55,'2009-6-9 12:00:42'
UNION ALL
SELECT 11,41,43,'2009-6-9 12:59:30'
--查询结果
SELECT A*1.0/FCount AS A平均值,B*1.0/FCount AS B平均值,C*1.0/FCount AS C平均值,Time
FROM(
SELECT SUM(a)AS A,SUM(b)AS B,SUM(c)AS C,
CONVERT(char(10),time,121)+' '+LTRIM(DATEPART(hour,time))+':00:00' AS Time,COUNT(*)AS FCount
FROM TestA
GROUP BY CONVERT(char(10),time,121),DATEPART(hour,time)
)AS T
--SELECT 1/2 =0 SELECT 1./2 =0.5 SELECT 1.0/2=0.5
当前名称:sqlserver平均数,平均值 sql
URL标题:http://pwwzsj.com/article/hccihj.html