I have a table order n a table payment. I need to go to the last record in payment table n perform a check on datepaid. I achieved this by using query with last(paymentid). I want to know tht if datepaid of last paymentid is null. Query should fetch the data of previous paymentid for a specific order where the datepaid is not null. How this can be done? Can someone help me?