0% found this document useful (0 votes)
20 views

SQL Answers

This document contains 5 SQLite queries: 1) Counts the number of invoices, 2) Counts customers with a balance over $500, 3) Generates a listing of customer purchases including subtotals for each invoice line number, 4) Lists customer balances that have made purchases this invoice cycle, 5) Finds customers that did not make purchases this period.

Uploaded by

Himanshu Kunwar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

SQL Answers

This document contains 5 SQLite queries: 1) Counts the number of invoices, 2) Counts customers with a balance over $500, 3) Generates a listing of customer purchases including subtotals for each invoice line number, 4) Lists customer balances that have made purchases this invoice cycle, 5) Finds customers that did not make purchases this period.

Uploaded by

Himanshu Kunwar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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