---
title: "Discussion on \"When ORDER BY and NULL work together\" | Hashnode"
description: "Discussion on \"When ORDER BY and NULL work together\". When we would like to sort the result-set in ascending or descending, we can use ORDER BY in SQL query. In Rails, we can use order which is derived from ActiveRecord::QueryMethods. For example,\nArticle.all.order(published_at: :desc)\n\nLet's focus on t..."
url: "https://hashnode.com/posts/when-order-by-and-null-work-together/65c47c0bab8190f7d87245c4"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [When ORDER BY and NULL work together](https://lynnbright.com/when-order-by-and-null-work-together?utm_source=hashnode&utm_medium=feed)

When we would like to sort the result-set in ascending or descending, we can use ORDER BY in SQL query. In Rails, we can use order which is derived from ActiveRecord::QueryMethods. For example, Article.all.order(published\_at: :desc) Let's focus on t...

Sep 3, 2021 · 3 min read · lynnbright.com  
Read the article

-   [#postgresql](https://hashnode.com/tag/postgresql)

## Written by

[Lynn Chang](https://hashnode.com/@Lynnbright)

@Lynnbright · Taipei, Taiwan

  
[View profile](https://hashnode.com/@Lynnbright)

Rails Developer

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
