Couchbase ORDER BY

I have a ORDER BY a DESC, GREATEST(b,c) DESC CLAUSE , a, b, and c are nullable

When we have multiple records with null a , the order ignores GREATEST(b,c) DESC part, WHY?

Could you please more specific about ignores with example?

ORDER By first, second, third.

If there is duplicates in first, second will get into play, if there duplicates in second, third will will get in the play.

If there are multiple nulls in a , with in the nulls GREATEST(b,c) DESC is in play.

Are you looking ORDER BY IFMISSINGORNULL(a,GREATEST(b,c)) DESC

https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/orderby.html

1 Like

@vsr1 thanks for your response, I see that some nullable fields are missing and the order fixed by using IFMISSINGL(a) DESC ,GREATEST(b,c) DESC