Question

In: Computer Science

Write the SQL queries that accomplish the following tasks using the AP Database 9. Write a...

Write the SQL queries that accomplish the following tasks using the AP Database

9. Write a select statement to show the invoicelineitemdescriptions that have the total invoicelineitemamount >1000 and the number of accountno is >2.

10. Write a select statement that returns the vendorid, paymentsum of each vendor, and the number of invoices of each vendor, where paymentsum is the sum of the paymentotal column. Return only the top ten vendors who have been paid the most and the number of invoices is >5.

Solutions

Expert Solution

1)Write a select statement to show the invoicelineitemdescriptions that have the total invoicelineitemamount >1000 and the number of accountno is >2.

SELECT InvoiceLineItemDescription

FROM InvoiceLineItems

WHERE InvoiceLineItemAmount>1000 AND AccountNo > 2;

2) Write a select statement that returns the vendorid, paymentsum of each vendor, and the number of invoices of each vendor, where paymentsum is the sum of the paymentotal column. Return only the top ten vendors who have been paid the most and the number of invoices is >5.

// In 2 ways second question can be done:

SELECT TOP 10 VendorName, SUM(PaymentTotal) AS Payments

FROM Vendors V, Invoices I

WHERE V.VendorID = I.VendorID

GROUP BY V.VendorID, VendorName

HAVING COUNT(*)>5;

OR

SELECT VendorName, SUM(PaymentTotal) AS Payments

FROM Vendors V, Invoices I

WHERE V.VendorID = I.VendorID

GROUP BY V.VendorID, VendorName

HAVING COUNT(*)>5

LIMIT 10;


Related Solutions

This is t a relational database please write SQL queries to solve the listed questions. The...
This is t a relational database please write SQL queries to solve the listed questions. The database is a variation of the “Movie Database” . There are several differences in it, so look it over carefully before writing your SQL queries Notes: TheaterNum, MovieNum, and ActorNum are numeric primary key fields in their respective tables. Movie and actor names are not assumed to be unique unless specified otherwise in a question. In the THEATER table, Capacity is the number of...
Create the following SQL queries using the lyrics database below 1. List the first name, last...
Create the following SQL queries using the lyrics database below 1. List the first name, last name, and region of members who do not have an email. 2. List the first name, last name, and region of members who do not have an email and they either have a homephone ending with a 2 or a 3. 3. List the number of track titles that begin with the letter 's' and the average length of these tracks in seconds 4....
Please create the SQL queries using the lryics database under question 4 and use "select *...
Please create the SQL queries using the lryics database under question 4 and use "select * from..." after each query to show the effects of your data manipulation query. Thanks for help 1. The title 'Time Flies' now has a new track, the 11th track 'Spring', which is 150 seconds long and has only a MP3 file. Insert the new track into Tracks table (Don’t hand-code any data for insert that can be looked up from the Titles table). 2....
For Problems 1–4, using the STORES Database, formulate SQL queries, Hand in a listing of each...
For Problems 1–4, using the STORES Database, formulate SQL queries, Hand in a listing of each query and its output. 1. (10 Points) For each customer, list each stock item ordered, the manufacturer, the quantity ordered, and the total price paid. Include the following columns in the order given below: From Customer Table:              Company From Stock Table:                      Description From the Manufact Table:        Manu_Name From the Items Table:                                Quantity, Total Price Order the output by Company and Description....
Using your downloaded DBMS (MS SQL Server or MySQL), write SQL queries that inserts at least...
Using your downloaded DBMS (MS SQL Server or MySQL), write SQL queries that inserts at least three rows in each table. For the On-Demand Streaming System, First, insert information for multiple users, at least three video items and insert the three different types of subscriptions (Basic, Advanced, Unlimited) into the database. Then insert at least three user subscriptions. Execute the queries and make sure they run correctly
7. Using the provided schema of a Purchase Order Administration database, write the following queries in...
7. Using the provided schema of a Purchase Order Administration database, write the following queries in SQL. (In the schema, bold attributes are primary keys and italicized attributes are foreign keys.) SUPPLIER (SUPNR, SUPNAME, SUPADDRESS, SUPCITY, SUPSTATUS) SUPPLIES (SUPNR, PRODNR, PURCHASE_PRICE, DELIV_PERIOD) PRODUCT (PRODNR, PRODNAME, PRODTYPE, AVAILABLE_QUANTITY) PO_LINE (PONR, PRODNR, QUANTITY) PURCHASE_ORDER (PONR, PODATE, SUPNR) 7d) Write a nested SQL query to retrieve the supplier number, supplier name, and supplier status of each supplier who has a higher supplier status...
Write the following SQL queries and show the corresponding output of the DBMS: 1) Write an...
Write the following SQL queries and show the corresponding output of the DBMS: 1) Write an SQL statement to display all the information of all Nobel Laureate winners. 2) Write an SQL statement to display the string "Hello, World!". 3) Write an SQL query to display the result of the following expression: 2 * 14 +76. 4) Write an SQL statement to display the winner and category of all Laureate winners. 5) Write an SQL query to find the winner(s)...
In this assignment, you are required to write the SQL statements to answer the following queries...
In this assignment, you are required to write the SQL statements to answer the following queries using PostgreSQL system. The SQL statements comprising the DDL for Henry Books Database are given to you in two files. For that database, answer the following queries. Create the files Q1 to Q10 in PostgreSQL. Do follow the restrictions stated for individual queries. 1. List the title of each book published by Penguin USA. You are allowed to use only 1 table in any...
Please use the books database pasted under question 4 to design the following SQL queries. Use...
Please use the books database pasted under question 4 to design the following SQL queries. Use any method such as subqueries, equi-join/inner-join, outer join, EXISTS 1. Find the name(s) of the publisher(s) who have published the computer book. 2. Find the name(s) of the author(s) that have authored more than one books. 3. Find the name(s) of the publisher(s) who published the least expensive book. 4. Find the name(s) of the author(s) who wrote the book with the greatest number...
Please use the books database pasted under question 4 to design the following SQL queries. Use...
Please use the books database pasted under question 4 to design the following SQL queries. Use any method such as subqueries, equi-join/inner-join, outer join, EXISTS 1. List the title_name and book type of the books that are published earlier than the earliest biography book 2. List the title_name and book type of the books published by 'Abatis Publishers' 3. Find the name(s) of the publisher(s) that have not published any book 4. Find the name(s) of the publisher(s) who have...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT