Premium Essay

Nt1330 Unit 2 Case 6.1

Submitted By
Words 539
Pages 3
Chapter 6
1. Write a SELECT statement that returns one row for each vendor in the Invoices table that contains these columns:
The vendor_id column from the Vendors table The sum of the invoice_total columns in the Invoices table for that vendor.
This should return 34 rows.

Answer:

SELECT vendor_id, SUM (invoice_total) AS invoice_total_sum

FROM invoices

GROUP BY vendor_id

2. a. Write a SELECT statement that returns one row for each vendor that contains these columns: The vendor_name column from the Vendors table
The sum of the payment_total columns in the Invoices table for that vendor b. Sort the result set in descending sequence by the payment total sum for each vendor.

Answer:

SELECT vendor_name, SUM (payment_total) AS payment_total_sum …show more content…
Return only those rows where the count of the line items is greater than 1. This should return 10 rows.

c. Group the result set by account descriptions.

d. Sort the result set in descending sequence by the sum of the line item amounts.

Answer:

SELECT account_description, COUN T(*) AS line_item_count, SUM (line_item_amt) AS line_item_amt_sum

FROM general_ledger_accounts gl JOIN invoice_line_items li

ON gl.account_number = li.account_number

GROUP BY gl.account_description

HAVING COUNT (*) > 1
ORDER BY line_item_amt_sum DESC

5. Modify the solution to exercise 4 so it returns only invoices date in the second quarter of 2014 (April 1, 2014 to June 30, 2014). This should still return 10 rows but with some different line item counts for each vendor. Hint: Join to the Invoices table to code a search condition base on invoice_date.

Answer:

SELECT account_description, COUNT (*) As line_item_count, SUM (line_item_amt) AS line_item_amt_sum

FROM general_ledger_accounts gl JOIN invoice_line_items li

ON gl.account_number = li.account_number

JOIN invoices i

ON li.invoice_id = i.invoice_id

WHERE invoice_date BETWEEN '01-Apr-2014' AND '30-June-2014'

GROUP BY gl.account_description

HAVING COUNT (*) >

Similar Documents

Premium Essay

Test

...Windows environment. Windows Security Syllabus Where Does This Course Belong? This course is required for the Bachelor of Science in Information Systems Security program. This program covers the following core areas:    Foundational Courses Technical Courses BSISS Project The following diagram demonstrates how this course fits in the program:    IS4799 NT2799 IS4670 ISC Capstone Project Capstone ProjectCybercrime Forensics NSA    NT2580 NT2670  Introduction to  Information Security IS4680 IS4560 NT2580 NT2670 Email and Web Services Hacking and Introduction to  Security Auditing for Compliance Countermeasures Information Security Email and Web Services      NT1230 NT1330 Client-Server Client-Server  Networking I Networking II  IS3230 IS3350 NT1230 NT1330  Issues Client-Server Client-Server  SecurityContext in Legal Access Security Networking I Networking II   NT1110  NT1210 Structure and Introduction to  ComputerLogic Networking    IS3120 IS3110 NT1210 Network  Risk Management in Introduction to General Education / General Studies NT2580 NT2799 Communications Information Technology Introduction to Information Security NSANetworking Capstone Project IS4550 NT2640 Security Policies and Implementation IP NT2640 Networking IP Networking PT2520...

Words: 2305 - Pages: 10