How to make a view equivalent to the following SQL?

@cihangirb Thanks for your example.

How to do the full query… the “ORDER BY” part (numerically)?:

ORDER BY UIDValidity DESC, UID DESC