Comments (1)
Probably blocked by the same limitation like here #55058 (comment)
Check those approaches as well https://kb.altinity.com/altinity-kb-queries-and-syntax/top-n-and-remain/
Your particular query also can be done using "scalar" instead of cte.
WITH (
SELECT (id, kind, count() AS c)
FROM events
GROUP BY
id,
kind
ORDER BY c DESC
LIMIT 1
) AS s
SELECT
id,
kind,
count() AS c,
toStartOfInterval(time, toIntervalSecond(20)) AS timestamp,
s.3
FROM events AS t
WHERE (t.id = (s.1)) AND ((s.2) = t.kind)
GROUP BY
timestamp,
id,
kind
Query id: 2161d7c6-24da-4890-b422-44902fb00a69
┌─id─────┬─kind───┬───c─┬───────────timestamp─┬─tupleElement(s, 3)─┐
│ item 9 │ kind 9 │ 442 │ 2024-05-22 02:16:40 │ 6249 │
│ item 9 │ kind 9 │ 448 │ 2024-05-22 02:14:20 │ 6249 │
│ item 9 │ kind 9 │ 403 │ 2024-05-22 02:15:00 │ 6249 │
│ item 9 │ kind 9 │ 393 │ 2024-05-22 02:15:20 │ 6249 │
│ item 9 │ kind 9 │ 409 │ 2024-05-22 02:14:00 │ 6249 │
│ item 9 │ kind 9 │ 133 │ 2024-05-22 02:12:20 │ 6249 │
│ item 9 │ kind 9 │ 415 │ 2024-05-22 02:12:40 │ 6249 │
│ item 9 │ kind 9 │ 427 │ 2024-05-22 02:16:00 │ 6249 │
│ item 9 │ kind 9 │ 294 │ 2024-05-22 02:17:20 │ 6249 │
│ item 9 │ kind 9 │ 411 │ 2024-05-22 02:13:40 │ 6249 │
│ item 9 │ kind 9 │ 410 │ 2024-05-22 02:15:40 │ 6249 │
│ item 9 │ kind 9 │ 413 │ 2024-05-22 02:14:40 │ 6249 │
│ item 9 │ kind 9 │ 411 │ 2024-05-22 02:17:00 │ 6249 │
│ item 9 │ kind 9 │ 399 │ 2024-05-22 02:13:00 │ 6249 │
│ item 9 │ kind 9 │ 396 │ 2024-05-22 02:16:20 │ 6249 │
│ item 9 │ kind 9 │ 445 │ 2024-05-22 02:13:20 │ 6249 │
└────────┴────────┴─────┴─────────────────────┴────────────────────┘
from clickhouse.
Related Issues (20)
- How to fix the leading space in prompt? HOT 6
- Unexpected result of WHERE for subquery with omitted GROUP BY and UNION ALL HOT 2
- Implementing "move part to shard" feature with Fixes HOT 7
- Logical error: 'mutation_pointer < it->second->entry->znode_name' (in stress test) HOT 1
- Alias column in subquery for `IN` is not expanded before skip index analysis HOT 2
- Improve the performance of `rb_contain` of 32-bit Bitmap
- OOM are prone to occur in window functions HOT 1
- The Recursive CTEs for generating Fibonacci Sequence produce wrong rows after n > 10. HOT 1
- There is a bug in decimal data comparison HOT 2
- Decimal
- Code: 241. DB::Exception: Memory limit (total) exceeded
- Code: 241. DB::Exception: Memory limit (total) exceeded HOT 1
- I need an unexpected set of privileges when inserting into the first source table in cascading materialized view HOT 1
- Unable to restore backups of tables with Object('json') column HOT 2
- Flaky / stuck: 02864_statistics_uniq HOT 1
- Wrong downcast from 'const DB::ColumnVector<UInt64>' to 'DB::ColumnLowCardinality' HOT 2
- Unexpected S3 reconciliation after a minor upgrade is causing high outgoing bandwidth usage, resource exhaustion HOT 2
- Optimize injective functions with several arguments inside of Uniq functions
- Apply LIMIT in GROUP BY
- S3Queue Log Status Ignores Failed Downstream Materialized Views HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clickhouse.