Skip to content
Advertisement

How to order a query result by two columns with nulls last in one of the columns

I have the following table ‘client’

I want to fetch all rows from this table ordered by ID Desc, with nulls in the column filecount ordered last.

So after the sorting I would like to get the following order:

I tried the following but it doesn’t work:

Advertisement

Answer

I would use a CASE expression here:

screen capture from demo link below

Demo

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement