[
https://issues.apache.org/jira/browse/CALCITE-6830?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17926715#comment-17926715
]
Lantao Jin commented on CALCITE-6830:
-------------------------------------
I tried in Oracle:
{code}
-- create
CREATE TABLE EMPLOYEE (
empId NUMBER PRIMARY KEY,
name VARCHAR2(15) NOT NULL,
dept VARCHAR2(10) NOT NULL
);
-- insert
INSERT INTO EMPLOYEE VALUES (1, 'Clark', 'Sales');
INSERT INTO EMPLOYEE VALUES (2, 'Dave', 'Accounting');
INSERT INTO EMPLOYEE VALUES (4, 'Ava', 'Sales');
-- fetch
SELECT avg(empId) FROM EMPLOYEE;
{code}
Output:
{code}
AVG(EMPID)
----------
2.33333333
{code}
> AVG aggregate function with integer argument type return wrong type
> -------------------------------------------------------------------
>
> Key: CALCITE-6830
> URL: https://issues.apache.org/jira/browse/CALCITE-6830
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.39.0
> Reporter: Lantao Jin
> Priority: Major
> Labels: pull-request-available
>
> To reproduce (agg.iq)
> {code:java}
> !use post
> !set outputformat mysql
> SELECT avg(deptno) as a FROM emp;
> {code}
> Should return 22.1429, but returns 22.
> This behavior is different from other databases.
> Since the AVG agg with integer argument returns wrong type, the behaviors of
> var_pop, var_samp, stddev_pop, stddev_samp and stddev are wrong either.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)