0

I have a array int[] field in my table and want to get only these fields who have int[] field size >= 3 and <= 5.

I tried something like this :

SELECT cadinality(tt.numbers) >= 3, tt.customer_id 
FROM table_table tt 
LIMIT 50 

but this return weird column with with checkmark, but it should return fields tt.numbers (only with size => 3 and <= 5).

1
  • please add some sample data and expected output Commented Oct 8, 2019 at 12:49

1 Answer 1

1

Your query returns all rows from your table, but instead of returning the numbers column you are returning a boolean expression that shows if the cardinality of the numbers column is bigger than 2.

If you want to limit the number of rows, you need a WHERE clause:

SELECT tt.numbers, tt.customer_id 
FROM table_table tt 
WHERE cadinality(tt.numbers) between 3 and 5
LIMIT 50;
cadinality(tt.numbers) between 3 and 5

is a shorthand notation for

cadinality(tt.numbers) >= 3 and cadinality(tt.numbers) <= 5 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.