tandem
tandem

Reputation: 2238

Get all columns with groupby clickhouse

I'm trying to get all columns in clickhouse for the students with number of questions greater than 1. What am I missing?

SELECT * FROM table_1 PREWHERE IDNUMBER IN (SELECT IDNUMBER, COUNT(QUESTIONS) as XXX FROM table_1 GROUP BY IDNUMBER HAVING XXX > 1)

This is the error I got:

DB::Exception: Number of columns in section IN doesn't match. 1 at left, 2 at right.: While executing MergeTreeThread

Upvotes: 0

Views: 1345

Answers (1)

GMB
GMB

Reputation: 222482

The subquery should return just one column, while it contains two:

SELECT * 
FROM table_1 PRE
WHERE IDNUMBER IN (SELECT IDNUMBER FROM table_1 GROUP BY IDNUMBER HAVING COUNT(*) > 1)

Upvotes: 1

Related Questions