Skip to content

LAST function in subquery #7885

Closed
Closed
@nordewal

Description

First of all, I love the great new subquery feature - it helps me in many cases where a specific function etc. is not (yet) available.

But I see an issue when using the LAST function in combination with subqueries:

Using the TOP function I get a correct count of the values in the database:

> SELECT count(*) FROM (SELECT top("value", 1) FROM "consul_value" GROUP BY *)
name: consul_value
time                 count_top
----                 ---------
1970-01-01T00:00:00Z 439

But using the LAST function, I get a way too long number:

> SELECT count(*) FROM (SELECT last("value") FROM "consul_value" GROUP BY *)
name: consul_value
time                 count_last
----                 ----------
1970-01-01T00:00:00Z 2

It seems that somehow only two values make it from the subquery to the outer query when using the LAST function:

SELECT last FROM (SELECT last("value") FROM "consul_value" GROUP BY *)
name: consul_value
time                           last
----                           ----
2017-01-25T17:14:26.65126633Z  0
2017-01-25T17:14:26.651284406Z 0
SELECT top FROM (SELECT top("value", 1) FROM "consul_value" GROUP BY *)
name: consul_value
time                           top
----                           ---
2017-01-25T13:30:44.401091Z    0
2017-01-25T13:30:44.401105Z    1
2017-01-25T13:30:44.401116Z    0
2017-01-25T13:30:44.401128Z    0
2017-01-25T13:30:44.40314Z     1
2017-01-25T13:30:44.403162Z    0
2017-01-25T13:30:44.403181Z    0
2017-01-25T13:30:44.403195Z    1
2017-01-25T13:30:44.403211Z    0
2017-01-25T13:30:44.403225Z    0
2017-01-25T13:30:44.403244Z    1
2017-01-25T13:30:44.403257Z    0
2017-01-25T13:30:44.403297Z    0
2017-01-25T13:30:46.631056Z    0
(...)

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions