Subqueries and group by clause

Hi,
I have a query to get configuration data every day.
I try to extract stats from that.
I change 3 versions last week.

  • subquery is working fine : extracting only last data for each name
  • if I run the query without “group by version”, it is getting me 37 names (which is right)
  • if I run the query with a “group by version”, it is getting me 40 names…It adds 3 results that were not present in the subquery (because I filtered on the last data).

Here is the query :
select count(name) from (SELECT version, last(time) FROM “mymeasurement” GROUP BY “name”) group by “version”

I don’t understand how can I have more results in the query than I have in the subquery…

thanks for your ideas,
vinny

Hi Vinny ,
last(time) in your subquery seems strange , should that be last(“name”) ?

LAST(field_key)
Returns the newest field value (determined by timestamp) associated with the [field key]