Use Ap

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

USE AP

SELECT InvoiceNumber , InvoiceTotal


from Invoices
order by InvoiceTotal;

-------------------------------------------------------------------------------
SELECT InvoiceTotal , PaymentTotal , CreditTotal , InvoiceTotal - PaymentTotal -
CreditTotal AS BalanceDue
FROM Invoices;
--------------------------------------------------------------------------------
SELECT InvoiceNumber , InvoiceDate , InvoiceTotal - InvoiceTotal - PaymentTotal -
CreditTotal AS BALANCE2018
FROM Invoices;
---------------------------------------------------------------------------------
SELECT InvoiceTotal , PaymentTotal , CreditTotal , InvoiceTotal - PaymentTotal -
CreditTotal AS UIGV2018
FROM Invoices
WHERE (InvoiceDate > '01/01/2016'
OR InvoiceTotal > 500)
AND InvoiceTotal - PaymentTotal - CreditTotal > 0;
------------------------------------------------------------------------------------
-
SELECT InvoiceNumber , VendorName
FROM Vendors JOIN Invoices
ON Vendors.VendorID = Invoices.VendorID;

------------------------------------------------------------------------------------
---
SELECT InvoiceNumber , VendorName , InvoiceDueDate , InvoiceTotal - PaymentTotal -
CreditTotal AS BalanceDue
FROM Vendors AS v JOIN Invoices AS i
ON v.VendorID = i.VendorID
WHERE InvoiceTotal - PaymentTotal - CreditTotal > 0
ORDER BY InvoiceDueDate DESC;
------------------------------------------------------------------------------------
---
SELECT VendorName , InvoiceNumber , InvoiceTotal
FROM Vendors LEFT JOIN Invoices
ON Vendors.VendorID = Invoices.VendorID
ORDER BY VendorName;

SELECT InvoiceNumber , VendorName


FROM Vendors JOIN Invoices
ON Vendors.VendorID = Invoices.VendorID;

You might also like