Quantcast
Channel: User Graygood - Stack Overflow
Viewing all articles
Browse latest Browse all 32

Select only rows with max date

$
0
0

In clickhouse table I have multiple rows for one _id. What I want is to get only one row for each _id where column _status_set_at has its max value. That's what I am currently at:

SELECT _id, max(_status_set_at), count(_id)FROM pikta.candidates_statesGROUP BY _id

output

Because I can't use max() function at WHERE clause, how to workaround this problem?count(_id) shows how many rows are there for each _id, if the query is correct, it should show 1.Also, as far as I concerned, there is no ON clause in Clickhouse database.

UPD: there is ON clause in Clickhouse


Viewing all articles
Browse latest Browse all 32

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>