网站建设资讯

NEWS

网站建设资讯

oracle平均值怎么算,oracle的平均函数

oracle 取平均值

你好,如果格式都如你贴图的一样的话可以用这种最笨的方式全一个个化成数值型,然后相加取值。

成都创新互联服务项目包括惠州网站建设、惠州网站制作、惠州网页制作以及惠州网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,惠州网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到惠州省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!

select CHECK_NORM,

(to_number(substr(CHECK_INFO, 1, 4)) +

to_number(substr(CHECK_INFO, 6, 4)) +

to_number(substr(CHECK_INFO, 11, 4)) +

to_number(substr(CHECK_INFO, 16, 4)) +

to_number(substr(CHECK_INFO, 21, 4)) +

to_number(substr(CHECK_INFO, 26, 4)) +

to_number(substr(CHECK_INFO, 31, 4)) +

to_number(substr(CHECK_INFO, 36, 4)) +

to_number(substr(CHECK_INFO, 41, 4)) +

to_number(substr(CHECK_INFO, 46, 4))) / 10

from 表名;

如果格式不统一,建议如2楼的,把字符型中的‘/’全部替换成‘+’,然后拼接出来一个sql,执行处理。

望采纳,谢谢。

oracle查询按记录个数,按比例汇总后求平均值

可以参考如下:

CREATE TABLE TEMP_AVG_SCORE

(T_DATA DATE,

T_NAME VARCHAR2(10),

T_SCORE NUMBER(10)

) ;

INSERT INTO TEMP_AVG_SCORE VALUES (TO_DATE('2015-01-01','YYYY-MM-DD'),'A',30) ;

INSERT INTO TEMP_AVG_SCORE VALUES (TO_DATE('2015-01-10','YYYY-MM-DD'),'A',40) ;

INSERT INTO TEMP_AVG_SCORE VALUES (TO_DATE('2015-01-15','YYYY-MM-DD'),'A',35) ;

INSERT INTO TEMP_AVG_SCORE VALUES (TO_DATE('2015-02-01','YYYY-MM-DD'),'B',120) ;

INSERT INTO TEMP_AVG_SCORE VALUES (TO_DATE('2015-02-10','YYYY-MM-DD'),'B',130) ;

INSERT INTO TEMP_AVG_SCORE VALUES (TO_DATE('2015-02-15','YYYY-MM-DD'),'B',150) ;

INSERT INTO TEMP_AVG_SCORE VALUES (TO_DATE('2015-02-20','YYYY-MM-DD'),'B',140) ;

COMMIT;

SELECT T.T_NAME 人员,

AVG(CASE

WHEN TO_CHAR(T.T_DATA, 'MM') = '01' AND T.NUM = 3 THEN

CASE

WHEN RN = 1 THEN

T.T_SCORE * 120 / 100

WHEN RN = 2 THEN

T.T_SCORE * 100 / 100

ELSE

T.T_SCORE * 80 / 100

END

WHEN TO_CHAR(T.T_DATA, 'MM') = '01' AND T.NUM = 4 THEN

CASE

WHEN RN = 1 THEN

T.T_SCORE * 120 / 100

WHEN RN = 2 THEN

T.T_SCORE * 110 / 100

WHEN RN = 3 THEN

T.T_SCORE * 90 / 100

ELSE

T.T_SCORE * 80 / 100

END

ELSE 0

END) 一月份,

AVG(CASE

WHEN TO_CHAR(T.T_DATA, 'MM') = '02' AND T.NUM = 3 THEN

CASE

WHEN RN = 1 THEN

T.T_SCORE * 120 / 100

WHEN RN = 2 THEN

T.T_SCORE * 100 / 100

ELSE

T.T_SCORE * 80 / 100

END

WHEN TO_CHAR(T.T_DATA, 'MM') = '02' AND T.NUM = 4 THEN

CASE

WHEN RN = 1 THEN

T.T_SCORE * 120 / 100

WHEN RN = 2 THEN

T.T_SCORE * 110 / 100

WHEN RN = 3 THEN

T.T_SCORE * 90 / 100

ELSE

T.T_SCORE * 80 / 100

END

ELSE

END) 二月

FROM (SELECT A.T_DATA,

A.T_NAME,

A.T_SCORE,

ROW_NUMBER() OVER(PARTITION BY A.T_NAME ORDER BY A.T_DATA DESC) RN,

B.NUM

FROM temp_avg_score A

LEFT JOIN (SELECT T_NAME, COUNT(1) NUM

FROM temp_avg_score

GROUP BY T_NAME) B ON A.T_NAME = B.T_NAME) T

GROUP BY T.T_NAME;

ORACLE中如果计算每日的平均值

select MG_ID,trunc(TIME,'dd') statDay,avg(FEED_IN_POWER) feedAvg from tableName group by MG_ID,trunc(TIME,'dd')


网页题目:oracle平均值怎么算,oracle的平均函数
网站链接:http://cdweb.net/article/hdjdop.html