I am re-engineering code written in the SQL, and I got a use of cardinality in an order by clause. So on which basis it is going to order the records?
e.g.
ORDER BY
cardinality(emp_ids),
earliest_due_date
where emp_ids are prepared like this
CAST(
collect(employee.emp_id)
AS
NumberList
) AS emp_ids
It is documented that the return is numeric:
So, your order by will return the
emp_idstable with the least number of rows in it first (empty ones as it will return null will come last).