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

Lab-Submission Template

The document contains SQL queries related to an assignment for a lab course. It includes various SELECT statements that interact with 'ap' and 'vendors' tables to retrieve information based on specific conditions. The queries focus on payment totals, vendor information, and invoice details.

Uploaded by

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

Lab-Submission Template

The document contains SQL queries related to an assignment for a lab course. It includes various SELECT statements that interact with 'ap' and 'vendors' tables to retrieve information based on specific conditions. The queries focus on payment totals, vendor information, and invoice details.

Uploaded by

tfm23456
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Comp1168 LabNoXX

Name: Bu , Omar
CRN: 50146
Student Id: 101550625
Date: Sun Mar 23, 2025

Ques on1
SELECT invoice_id, payment_total
FROM ap WHERE payment_total > (SELECT AVG(payment_total)
FROM ap);

Ques on2
SELECT invoice_number, invoice_date, invoice_total
FROM ap WHERE vendor_id IN (SELECT vendor_id FROM vendors
WHERE vendor_state = ‘California');

Ques on3
SELECT v.vendor_id, v.vendor_name, v.vendor_state
FROM vendors v LEFT OUTER JOIN ap a ON v.vendor_id = a.vendor_id
WHERE a.vendor_id IS NULL;

Ques on4
SELECT v.vendor_name, a.invoice_number, a.invoice_total
FROM vendors v JOIN ap a ON v.vendor_id = a.vendor_id
ti
ti
ti
ti
tt
WHERE a.invoice_total > ALL (SELECT invoice_total FROM ap
WHERE vendor_id = 34);

Ques on5
SELECT v.vendor_id, v.vendor_name, v.vendor_state
FROM vendors v WHERE NOT EXISTS (SELECT 1 FROM ap a
WHERE a.vendor_id = v.vendor_id);

Ques on6
SELECT v.vendor_name, (SELECT MAX(a.invoice_date) FROM ap a
WHERE a.vendor_id = v.vendor_id) AS Latest_Inv_Date
FROM vendors v WHERE EXISTS (SELECT 1 FROM ap a
WHERE a.vendor_id = v.vendor_id);
ti
ti

You might also like