Computers and Technology

1) Write a SELECT statement that returns two columns from the invoices table: vendorID and paymentSum where paymentSum is the SUM() of the paymentTotal column. (Since we have vendorID in the SELECT line, it must be in the GROUP BY clause.) Group the result set by vendorID and ORDER BY paymentSum. (34 rows)2) Write a SELECT statement that returns two columns: vendorName and paymentSum where paymentSum is the SUM() of the paymentTotal column. (Since we have vendorName in the SELECT line, it must be in the GROUP BY clause.) Group the result set by vendorName and ORDER BY paymentSum. (This time 33 rows!!? This tells us something! Review problem five from chapter four, part b)3) Write a SELECT statement that returns three columns: vendorName, invoiceCount, and invoiceSum where invoiceCount is the COUNT() of the rows returned and invoiceSum is the SUM() of the invoiceTotal column Group the result set by vendorName. Sort the result set such that the with the greatest number of invoices appears first. I have 33 rows; here are my first ten:vendorName invoiceCount invoiceSumFederal Express Corporation 47 4378.02United Parcel Service 9 23177.96Zylka Design 8 6940.25Pacific Bell 6 171.01Malloy Lithographing Inc 5 119892.41Roadway Package System, Inc 4 43.67Blue Cross 3 564.00Cardinal Business Media, Inc. 2 265.36Compuserve 2 19.90Data Reproductions Corp 2 21927.314) Write a SELECT statement that returns three columns: accountDescription, lineItemCount, and lineItemSum. lineItemCount is the number of entries in the invoiceLineItems table that have that accountDescription. lineItemSum is the sum of the invoiceLineItemAmount column for that accountDescription. Filter the set to include only groups with lineItemCount greater than 1. Group the set by accountDescription and sort it by descending lineItemCount. Hint: Join the glAccounts table to the invoiceLineItems table. Join the tables with an INNER JOIN on accountNoIf you alias COUNT(*) AS lineItemCount on the SELECT line you may use the alias on the ORDER BY line, but not in the HAVING clause! You will have to use COUNT(*)>1 in the HAVING clause. Here are the data I returned:accountDescription lineItemCount lineItemSumFreight 60 27599.65Book Printing Costs 8 148759.97Book Production Costs 8 6175.12Telephone 7 266.01Direct Mail Advertising 6 3900.77Books, Dues, and Subscriptions 6 5207.32Computer Equipment 3 2137.05Group Insurance 3 564.00Office Supplies 3 175.80Outside Services 3 13394.105) Query #4 has an issue! How do we know that don't have two or more different accountNo values with identical accountDescription? Nothing is blocking that insert! When we get to chapter 11, you will block that problem; for now, we'll just check it. Write an SQL query that will check for duplicate accountDescription on different accountNo in the glAccounts table. Hint: Select both fields and count the accountNo; group on accountDescription and look for a count > 1. Well, there currently aren't any... we got lucky, I guess, but database professionals do not trust luck! to test it, insert an accountNo of 633 with a description of 'Cash' into the table and that'll give you something to find. Afterwards, just delete it.6) Modify the solution to exercise four to filter for invoices where the invoiceTotal is greater than 1000. (Add the invoices table to the join and put that condition in a WHERE clause; it's easy!)Here's what I got:accountDescription lineItemCount lineItemSumFreight 9 23177.96Book Printing Costs 7 148674.66Outside Service 3 13394.10Book Production Costs 2 2197.46Books, Dues, and Subscriptions 2 4008.00Direct Mail Advertising 2 2949.637) Write a select statement that returns four columns: vendorName, accountDescription, lineItemCount, and lineItemSum; lineItemCount is the row count; lineItemSum is the SUM of the invoiceLineItemAmount column. For each vendor and accountNo (light bulb: that's probably the group by!) return the lineItemCount and lineItemSum sorted first by vendor, then by accountDescription. Notice that this one has vendorName (from vendors), lineItemSum (from invoiceLineItems) and accountDescription (from glAccounts). To make it better, you can only get from vendors to invoiceLineItems by going through invoices; thus, you have an INNER JOIN on four tables. Other than that, it's pretty straightforward.8) Write a SELECT statement that answers the question: "Which vendors are being paid from more than one account?" Return two columns: vendorName and the total number of accounts that apply to that vendor. Only include rows that have a count exceeding one. Discussion: You might well find a COUNT(DISTINCT... to be useful for this one. Essentially, what we need to count is in invoiceLineItems, so we don't need the glAccounts table like we did in #7 (It asked for the accountDescription!) It's a pretty straightforward join of three tables. (I see Wells Fargo Bank with 3 accounts and Zylka Design with 2).

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 03:30, brin1021
Jessie has received a contract to build a real-time application for a baker. however, the baker doesn't want to invest too much money. his only requirement is that he wants the customers to know which cupcakes are available at what time and in what quantity. so his core requirement is that the details of product should be in real time. what platform can jessie use to develop this application?
Answers: 1
image
Computers and Technology, 22.06.2019 05:00, yddlex
Modern businesses use different technologies to accomplish work tasks
Answers: 2
image
Computers and Technology, 22.06.2019 23:00, brooklynmikestovgphx
Suppose s, t, and w are strings that have already been created inside main. write a statement or statements, to be added to main, that will determine if the lengths of the three strings are in order by length, smallest to largest. that is, your code should determine if s is strictly shorter than t, and if t is strictly shorter than w. if these conditions hold your code should print (the boolean value) true. if not, your code should print false. (strictly means: no ties) example: if s, t, and w are "cat", "hats", and "skies" your code should print true - their lengths are 3-4-5; but if s, t, and w are "cats" "shirt", and "trust", then print false - their lengths are 4-5-5 enter your code in the box below
Answers: 2
image
Computers and Technology, 23.06.2019 11:30, leapfroggiez
Auser is given read permission to a file stored on an ntfs-formatted volume. the file is then copied to a folder on the same ntfs-formatted volume where the user has been given full control permission for that folder. when the user logs on to the computer holding the file and accesses its new location via a drive letter, what is the user's effective permission to the file? a. read b. full control c. no access d. modify e. none of the above
Answers: 1
Do you know the correct answer?
1) Write a SELECT statement that returns two columns from the invoices table: vendorID and paymentSu...

Questions in other subjects:

Konu
Mathematics, 21.02.2020 11:14
Konu
Mathematics, 21.02.2020 11:20