id | amount
-----------
1 | 100 |
2 | 0 |
3 | 0 |
4 | 200 |
5 | 0 |
6 | 0 |
I have this table in which the value column will have frequent values greater than 0. I am trying to figure out a SQL query that will print values between the first greater than 0 value and the second greater than 0 value.
for the above table, the output will be
id | amount
-----------
1 | 100 |
2 | 0 |
3 | 0 |
I am not getting what kind of condition will be applied to achieve this. I have tried the Group By but it only counts the total number of the same value.
I also thought of giving each value a unique number such as below
id | Serial number | amount
---------------------------
1 | 1 | 100 |
2 | 1 | 0 |
3 | 1 | 0 |
4 | 1 | 200 |
5 | 1 | 0 |
6 | 1 | 0 |
But again I was unable to display the data with query since I am confused about how to do it.