从品牌网站建设到网络营销策划,从策略到执行的一站式服务
select sum(求和栏位),sum(求和栏位)/count(*) --总和,平均值
网站建设哪家好,找创新互联建站!专注于网页设计、网站建设、微信开发、微信平台小程序开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了富顺免费建站欢迎大家使用!
from 表名
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
select convert(varchar,time,23),datepart(hh,time),avg(valueavg),max(valueavg)
from tb group by convert(varchar,time,23),datepart(hh,time)
SELECT 省, 市, 县, year(日期) 年份, AVG(ABS(闪电强度)) 闪电强度绝对值的平均值
FROM HUBEISHENG
GROUP BY 省, 市, 县,year(日期)
--已出结果 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
成都网站建设公司地址:成都市青羊区太升南路288号锦天国际A座10层 建设咨询028-86922220
成都快上网科技有限公司-四川网站建设设计公司 | 蜀ICP备19037934号 Copyright 2020,ALL Rights Reserved cdkjz.cn | 成都网站建设 | © Copyright 2020版权所有.
专家团队为您提供成都网站建设,成都网站设计,成都品牌网站设计,成都营销型网站制作等服务,成都建网站就找快上网! | 成都网站建设哪家好? | 网站建设地图