Question
Please help me with the following Queries: FOR QUERIES 1-4 : - What each query is requesting from the database. - Include descriptions for what
Please help me with the following Queries:
FOR QUERIES 1-4:
- What each query is requesting from the database.
- Include descriptions for what ALL of the following SQL keywords are doing in each query they are present in: SELECT, FROM, and ORDER BY
- Include a description of how the tables are being joined together.
QUERY 1
SELECT vendor_name, invoice_number, invoice_total
FROM vendors LEFT JOIN invoices
ON vendors,vendor_id = invoices.vendor_id
ORDER BY vendor_name
QUERY 2
SELECT deparmtnet_name, d.department_number, last_name
FROM departments d
LEFT JOIN employees e
ON d.department_number =e.department_number
ORDERS BY department_name
QUERY 3
SELECT department_name, last_name, project_number
FROM departments d
LEFT JOIN employees e
ON d.department_number =e.department_number
LEFT JOIN projects p
ON e.employee-id = p. employee_id
ORDER BY department_name, last_name
QUERY 4
SELECT department_name, last_name, project_name
FROM departments d
JOIN employees e
ON d. department_number = e.department_number
LEFT JOIN projects p
ON e.employees_id = p.employee_id
ORDER BY department_name, last_name
FOR QUERIES 5-7
- What each query is requesting from the database.
- Include descriptions for what ALL of the following SQL keywords are doing in each query they are present in: SELECT, FROM, WHERE, and ORDER BY
- Include a description of how the tables are being unioned together.
QUERY 5
SELECT `Active` AS source, invoice_number, invoice_date, invoice_total
FROM paid_invoices
WHERE invoice_date>= `2014-06-01
UNION
SELECT `Paid AS source, invoice_number, invoice_date, invoice_total
FROM paid_invoices
WHERE invoice_date>= `2014-06-01
ORDER BY invoice_total DESC
QUERY 6
SELECT `Active` AS source, invoice_number, invoice_date, invoice_total
FROM paid_invoices
WHERE invoice_total payment_total credit_total> 0
UNION
SELECT Paid AS source, invoice_number, invoice_date, invoice_total
FROM invoices
WHERE invoice_total payment_total credit_total<= 0
ORDER BY invoice_total DESC
QUERY 7
Select invoice_number, vendor_name, 33% Payment AS payment_type, invoice_total AS total, invoice_total * 0.333 AS payment
FROMinvoivces JOIN vendors
ON invoices.vendor_id = vendors.vendor_id
WHERE invoice_total> 10000
UNION
Select invoice_number, vendor_name, 50% Payment AS payment_type, invoice_total AS total,invoice_total * 0.5 AS payment
FROMinvoivces JOIN vendors
ON invoices.vendor_id=vendors.vendor_id
WHERE invoice_total BETWEEN 500 AND 10000
UNION
Select invoice_number, vendor_name, Full Payment AS payment_type, invoice_total AS total,invoice_total AS payment
FROM invoivces JOIN vendors
ON invoices.vendor_id =vendors.vendor_id
WHERE invoice_total< 500
ORDER BY payment_type, vendor_name, invoice_number
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started