@cortez.connelly
To count the occurrences of each element in an array in Presto, you can use the UNNEST
function along with GROUP BY
and COUNT
functions. Here's an example query:
1 2 3 4 |
SELECT element, COUNT(*) AS occurrences FROM your_table CROSS JOIN UNNEST(your_array_column) AS t(element) GROUP BY element |
Replace your_table
with the name of your table and your_array_column
with the name of the array column you want to count the occurrences for. This query will output the element and the number of times it appears in the array column.