I have the data below in a sql table,
ID | supplier | Supplier_Due | Date |
1 | S-0003 | 14850 |2020-11-09
2 | S-0003 | 850 |2020-11-09
3 | S-0003 | 21750 |2020-11-13
4 | S-0003 | 975 |2020-11-15
5 | S-0003 | 75 |2020-11-17
let assume the user wants to get data of 2020-11-13 which is
3 | S-0003 | 21750 |2020-11-13
but i'd like to get the previous supplier due as well before the date specified which is
850
along with
3 | S-0003 | 21750 |2020-11-13
so the actual query i wanna get is this
ID | supplier | Supplier_Due | Date | Previous Due
3 | S-0003 | 21750 |2020-11-13 | 850
and if there is no previous due i wanna return
ID | supplier | Supplier_Due | Date | Previous Due
3 | S-0003 | 21750 |2020-11-13 | 0.00
i couldn't even figure out how to write the query because i dont understand how to go about it