Skip to content

The median function behaves inconsistently #1360

Description

@LLMTesting-Ojiken

Here's an example:

DROP TABLE IF EXISTS t0;
DROP TABLE IF EXISTS v0;

CREATE TABLE t0
(
    c0 INT
);

CREATE TABLE v0
(
    c0 INT
);

INSERT INTO t0 (c0)
VALUES (NULL),
       (0.0280020140016927),
       (NULL);

INSERT INTO v0 (c0)
VALUES (1);

select median(col)
from (
         SELECT DISTINCT (json_quote(COALESCE(t0.c0, v0.c0))) as col
         FROM v0,
              t0
     );

If you run this code on the SQlite3 website, select will not be searchable and will throw an error.
Running it against the project's jar would produce an output of 0.5, but even that would be wrong; the correct answer would be 0.514001007000846.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement:SQLiteEnhancement about sqlite featuresreleasedIssue has been released

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions