Get the last non null value of a table coulm

Below is my table and from column B I want to get the value 3 in resultant.

A B
1 1
2 Null
3 2
4 Null
5 3
6 Null
7 Null
8 Null

>Solution :

Use a LIMIT query:

SELECT *
FROM yourTable
WHERE B IS NOT NULL
ORDER BY A DESC
LIMIT 1;

Leave a Reply