Database Queries for Data Analysis
VerifiedAdded on  2020/03/01
|13
|275
|39
Homework Assignment
AI Summary
This assignment focuses on various SQL queries designed for data analysis, including retrieving customer and invoice information, filtering data based on conditions, and aggregating results. It serves as a practical exercise for students to enhance their database management skills in the context of data science.

STUDENT DETAILS
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

1.
Query
SELECT invoice.INV_TOTAL FROM invoice;
2.
Query
SELECT * FROM vendor WHERE vendor.V_STATE IS NULL;
Query
SELECT invoice.INV_TOTAL FROM invoice;
2.
Query
SELECT * FROM vendor WHERE vendor.V_STATE IS NULL;

3.
Query
SELECT * FROM customer WHERE customer.CUS_BALANCE BETWEEN 200 and 300;
Query
SELECT * FROM customer WHERE customer.CUS_BALANCE BETWEEN 200 and 300;
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

4.
Query
SELECT customer.*,invoice.INV_TOTAL FROM customer
INNER JOIN invoice ON customer.CUS_CODE=invoice.CUS_CODE
HAVING invoice.INV_TOTAL>200;
Query
SELECT customer.*,invoice.INV_TOTAL FROM customer
INNER JOIN invoice ON customer.CUS_CODE=invoice.CUS_CODE
HAVING invoice.INV_TOTAL>200;
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

5.
Query
SELECT customer.CUS_FNAME,customer.CUS_LNAME FROM customer
WHERE customer.CUS_CODE IN (SELECT invoice.CUS_CODE FROM invoice);
Query
SELECT customer.CUS_FNAME,customer.CUS_LNAME FROM customer
WHERE customer.CUS_CODE IN (SELECT invoice.CUS_CODE FROM invoice);

6.
Query
SELECT customer.CUS_CODE,customer.CUS_FNAME,customer.CUS_LNAME FROM customer
INNER JOIN invoice ON customer.CUS_CODE=invoice.CUS_CODE
GROUP BY customer.CUS_CODE
HAVING SUM(invoice.INV_TOTAL)>(SELECT AVG(invoice.INV_TOTAL));
Query
SELECT customer.CUS_CODE,customer.CUS_FNAME,customer.CUS_LNAME FROM customer
INNER JOIN invoice ON customer.CUS_CODE=invoice.CUS_CODE
GROUP BY customer.CUS_CODE
HAVING SUM(invoice.INV_TOTAL)>(SELECT AVG(invoice.INV_TOTAL));
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

7.
Query
SELECT customer.CUS_FNAME,customer.CUS_LNAME FROM customer
WHERE customer.CUS_CODE NOT IN (SELECT invoice.CUS_CODE FROM invoice);
Query
SELECT customer.CUS_FNAME,customer.CUS_LNAME FROM customer
WHERE customer.CUS_CODE NOT IN (SELECT invoice.CUS_CODE FROM invoice);
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

8.
Query
SELECT customer.CUS_CODE,invoice.INV_TOTAL FROM customer
INNER JOIN invoice ON customer.CUS_CODE=invoice.CUS_CODE
ORDER BY invoice.INV_TOTAL DESC
LIMIT 1;
Query
SELECT customer.CUS_CODE,invoice.INV_TOTAL FROM customer
INNER JOIN invoice ON customer.CUS_CODE=invoice.CUS_CODE
ORDER BY invoice.INV_TOTAL DESC
LIMIT 1;

9.
Query
SELECT customer.CUS_FNAME,customer.CUS_LNAME,COUNT(invoice.CUS_CODE) FROM
customer
INNER JOIN invoice ON customer.CUS_CODE=invoice.CUS_CODE
GROUP BY customer.CUS_CODE;
Query
SELECT customer.CUS_FNAME,customer.CUS_LNAME,COUNT(invoice.CUS_CODE) FROM
customer
INNER JOIN invoice ON customer.CUS_CODE=invoice.CUS_CODE
GROUP BY customer.CUS_CODE;
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

10.
Query
SELECT customer.CUS_FNAME,customer.CUS_LNAME,invoice.INV_NUMBER,product.P_CODE,
product.P_DESCRIPT FROM customer
INNER JOIN invoice ON customer.CUS_CODE=invoice.CUS_CODE
INNER JOIN line ON invoice.INV_NUMBER=line.INV_NUMBER
INNER JOIN product ON line.P_CODE=product.P_CODE
WHERE customer.CUS_CODE=10018;
Query
SELECT customer.CUS_FNAME,customer.CUS_LNAME,invoice.INV_NUMBER,product.P_CODE,
product.P_DESCRIPT FROM customer
INNER JOIN invoice ON customer.CUS_CODE=invoice.CUS_CODE
INNER JOIN line ON invoice.INV_NUMBER=line.INV_NUMBER
INNER JOIN product ON line.P_CODE=product.P_CODE
WHERE customer.CUS_CODE=10018;
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

11.
Query
SELECT vendor.V_NAME FROM vendor
LEFT JOIN product ON vendor.V_CODE=product.V_CODE
INNER JOIN line ON line.P_CODE=product.P_CODE
WHERE vendor.V_CODE IN (SELECT vendor.V_CODE FROM PRODUCT)
AND product.P_CODE IN (SELECT line.P_CODE FROM line)
GROUP BY vendor.V_NAME;
Query
SELECT vendor.V_NAME FROM vendor
LEFT JOIN product ON vendor.V_CODE=product.V_CODE
INNER JOIN line ON line.P_CODE=product.P_CODE
WHERE vendor.V_CODE IN (SELECT vendor.V_CODE FROM PRODUCT)
AND product.P_CODE IN (SELECT line.P_CODE FROM line)
GROUP BY vendor.V_NAME;

12.
Query
SELECT product.P_CODE,product.P_DESCRIPT,SUM(line.LINE_UNITS) FROM product
INNER JOIN line ON product.P_CODE=line.P_CODE
GROUP BY product.P_CODE
HAVING SUM(line.LINE_UNITS)>10;
Query
SELECT product.P_CODE,product.P_DESCRIPT,SUM(line.LINE_UNITS) FROM product
INNER JOIN line ON product.P_CODE=line.P_CODE
GROUP BY product.P_CODE
HAVING SUM(line.LINE_UNITS)>10;
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide
1 out of 13
Related Documents

Your All-in-One AI-Powered Toolkit for Academic Success.
 +13062052269
info@desklib.com
Available 24*7 on WhatsApp / Email
Unlock your academic potential
Copyright © 2020–2025 A2Z Services. All Rights Reserved. Developed and managed by ZUCOL.