Im banging my head against the wall. I hope you can help
I have the following columns in my invoice table:
InvoiceNo | InvoiceDate | InvoicePaidDate | JobNumber |
---|
each JobNumber value will have 1 or more InvoiceNo I have a variable ('JobNo') that I will receive from an external system I need to use this variable to check :
- Check each invoice attached to the JobNo variable is paid or not using the InvoicePaidDate and return a string "Invoice 1234 IS PAID" or "Invoice 1232 IS NOT PAID", and
- Return 1 additional string if all invoices are paid "ALL INVOICES ARE NOW PAID"
Is it possible to do this with a single query?
Im stuck with a rumentary select statement:
Select Case
When InvoicePaidDate IS NULL then 'Invoice ' + InvoiceNo + ' Is Not Paid yet'
else 'Invoice ' + InvoiceNo + ' Is Paid ' END as PaymentStatus
From Invoices