I am pretty new to SQL and I was wondering if there is a way to count the number of elements in a text column, such as this on psql:
database => SELECT * FROM volume LIMIT 2;
id | column2 |
---|---|
0 | {"abc", "def", "ghi", "jkl"} |
1 | {"abc", "def", "ghi"} |
(2 rows)
Here, I would like to count the number of elements in the second variable, in total (over the whole dataset)
I usually use cardinality
:
select cardinality(col2)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.