SQL Answers

You might also like

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

1.

Write a query to count the number of invoices


sqlite> select count(INV_NUMBER) from INVOICE;

2. Write a query to count the number of customers with a customer balance over $500.
sqlite> select count(*) from CUSTOMER where CUS_BALANCE>500;
select * from CUSTOMER where CUS_BALANCE>500;

3. Generate the listing of customer purchases, including the subtotals for each of the invoice line
numbers.
sqlite> select P_CODE,LINE_PRICE from LINE group by INV_NUMBER,LINE_NUMBER;

4. List the balance characteristics of the customers who have made purchases during the
current invoice cycle—that is, for the customers who appear in the INVOICE table.

sqlite> select CUS_CODE,CUS_BALANCE from CUSTOMER where CUS_CODE IN (select


CUS_CODE from INVOICE);
5. Find the listing of customers who did not make purchases during the invoicing period.
sqlite> select CUS_CODE from CUSTOMER where CUS_CODE not IN (select CUS_CODE from
INVOICE);

You might also like