Skip to content

How do I group by derived columns? Also, are common table expressions supported? #4352

Answered by weiznich
grechkay asked this question in Q&A
Discussion options

You must be logged in to vote

It's always hard to answer questions that ask "Is it possible to do xyz", because almost anything is possible if you are willing to spend time implementing in.

In this case the built-in DSL does not support CTE yet, although that's something that might change in the future. That written: You likely don't need to use a CTE expression there at all as you could write that query as well as

SELECT 
  id % 2 AS mod,
  SUM(val) AS sum_val
FROM 
  Table
GROUP BY mod

or as

SELECT 
  id % 2,
  SUM(val) AS sum_val
FROM 
  Table
GROUP BY id % 2

The first variant would require column aliasing support in the DSL, which again is not supported yet. The second variant is technically supported, but I'm not…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by grechkay
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants