# Null last in order by in Mem SQL

**URL:** <https://www.singlestore.com/forum/t/null-last-in-order-by-in-mem-sql/4849>\
**Category:** Procedural SQL\
**Created:** [August 8, 2022, 5:41am UTC](https://www.singlestore.com/forum/t/null-last-in-order-by-in-mem-sql/4849 "2022-08-08T05:41:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![smartdnshail1](https://www.singlestore.com/forum/letter_avatar_proxy/v4/letter/s/a698b9/32.png) [@smartdnshail1](https://www.singlestore.com/forum/u/smartdnshail1)\
**Post date:** [August 8, 2022, 5:41am UTC](https://www.singlestore.com/forum/t/null-last-in-order-by-in-mem-sql/4849/1 "2022-08-08T05:41:15Z")

</div>

Can someone help me how to use Null last in Mem sqlMEM, in RDBMS we have option for null last but in Mem SQL it does not supports

---

<div class="post-metadata">

**Author:** ![hanson](https://www.singlestore.com/forum/user_avatar/www.singlestore.com/hanson/32/196_2.png) [@hanson](https://www.singlestore.com/forum/u/hanson)\
**Post date:** [August 8, 2022, 9:26pm UTC](https://www.singlestore.com/forum/t/null-last-in-order-by-in-mem-sql/4849/2 "2022-08-08T21:26:33Z")

</div>

SingleStore supports it:

```auto
singlestore> create table t(a int);
Query OK, 0 rows affected (0.02 sec)

singlestore> insert t values(1),(2),(null),(4);

singlestore> select a from t order by a;
+------+
| a |
+------+
| NULL |
| 1 |
| 2 |
| 4 |
+------+
4 rows in set (0.03 sec)

singlestore> select a from t order by a NULLS LAST;
+------+
| a |
+------+
| 1 |
| 2 |
| 4 |
| NULL |
+------+

singlestore> select @@memsql_version;
+------------------+
| @@memsql_version |
+------------------+
| 7.8.9 |
+------------------+

```

It also works in window functions, e.g.:

```auto
select a, rank() over (order by a nulls last) from t;
+------+-------------------------------------+
| a | rank() over (order by a nulls last) |
+------+-------------------------------------+
| 1 | 1 |
| 2 | 2 |
| 4 | 3 |
| NULL | 4 |
+------+-------------------------------------+

```
