Question

Write a SQL statement to retrieve the average number of pages per category

Write a SQL statement to retrieve the average number of pages per category

Homework Answers

Answer #1

Let suppose SQLTable is the table name, It is having two columns and multiple rows

Columns are pages and category,

category is same for some of the pages and we have to find the average of pages category wise

So, here we will use , GROUP BY clause to make group of each category

After that , we will use aggregate function AVG to find the average of pages for each category

Below is the final query:

SELECT AVG(pages),category from SQLTable GROUP BY category;

Example:

Below is the table:

pages category
90 C001
60 C001
80 C002
20 C002
20 C002

As per above query , below will be the output:

AVG(pages) category
75 C001
40 C002

so, by GROUP BY , category goes grouped C001 and C002

and average is found groupwise,

C001 - have 60,90 - whose average is 75

C002 - have 60,20,20 - whose average is 40

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
write an SQL SELECT statement for retrieve the name and income of customers without charges in...
write an SQL SELECT statement for retrieve the name and income of customers without charges in january 2020
Write the SQL queries that accomplish the tasks using the AP Database 1. Write a SQL...
Write the SQL queries that accomplish the tasks using the AP Database 1. Write a SQL statement to retrieve the InvoiceID, InvoiceDate, InvoiceTotal, BalanceDue, PaymentDate, and AgeofInvoices for the invoices that have more than 30 days of invoice age. Sort the result set by AgeofInvoice in a descending order. (Note: BalanceDue = InvoiceTotal-PaymentTotal-CreditTotal AgeofInvoice is the number of days difference between invoicedate and paymentdate.) 2. For each invoicedate that has more than one invoice, show the invoiceDate and calculate the...
7.11E Write an SQL query that retrieves the total available quantity of sparkling wines. Make sure...
7.11E Write an SQL query that retrieves the total available quantity of sparkling wines. Make sure to display this quantity as “TOTAL_QUANTITY” 7.12E Write a query to select all supplier numbers, together with their supplier name and total number of outstanding orders for each supplier. Include all suppliers in the result, even if there are no outstanding orders for that supplier at the moment. 7.17E Write an SQL query with ALL or ANY to retrieve the name of the product...
Write an SQL statement utilizing the WHERE, LIKE, and HAVING clauses that selects gender, and the...
Write an SQL statement utilizing the WHERE, LIKE, and HAVING clauses that selects gender, and the email addresses that belong to female users and have an email address that contains a number (0 to 9) within it. Create an alias for the resultant email column name and name it ‘Email Addresses Female With Numbers’.
implement in Oracle Sql please 5) Write a SELECT statement that answers this question: Which products...
implement in Oracle Sql please 5) Write a SELECT statement that answers this question: Which products have a list price that’s greater than the average list price for all products? Return the product_name and list_price columns for each product. Sort the results by the list_price column in descending sequence.
Write a SQL statement which joins the parts table with the supplier table and lists the...
Write a SQL statement which joins the parts table with the supplier table and lists the part_name, supplier_name for all parts in the part table. The supplier_id column in the suppliers table is the primary key in the suppliers table, and this key has been exported to the parts table where it is a foreign key. You should use an inner join for this query. Write a SQL statement which joins the parts table with the suppliers table and lists...
Using the Company database in Oracle, construct SQL queries for the following (note: I will make...
Using the Company database in Oracle, construct SQL queries for the following (note: I will make the files to create and populate the Company database available on Isadore shortly): List the last name and address of managers who have a dependent with the same first name as themselves. Retrieve the names of all employees who are directly supervised by ‘Franklin Wong’. Retrieve the names of employees in the Research department who work more than 20 hours per week on the...
Write a SQL statement for the following query: Relational Schema: Part( P #, PName, Producer, Year,...
Write a SQL statement for the following query: Relational Schema: Part( P #, PName, Producer, Year, Price) (P# is the primary key) Customer( C#, CName, City) (C# is the primary key) Supply(S#, P#, C#, Quantity, Amount, Date) (S# is the primary key) Query: For each Apple product supplied to more than 10 different customers in Chicago in 2020, list product number, product name, total supply quantity, and total supply amount. Sort the result by product name.
28. An editor wants to estimate average the number of pages in bestselling novels, so that...
28. An editor wants to estimate average the number of pages in bestselling novels, so that his estimate falls within 20 pages of the true average. Assuming that the standard deviation is 63 pages, how large a sample of bestselling novels is needed to achieve a. 90% confidence? b. 95% confidence? c. Identify the variable in this context d. Identify an individual in this context
The average number of pages for a simple random sample of 40 physics textbooks is 435....
The average number of pages for a simple random sample of 40 physics textbooks is 435. The average number of pages for a simple random sample of 40 mathematics textbooks is 410. Assume that all page length for each types of textbooks is normally distributed. The standard deviation of page length for all physics textbooks is known to be 55, and the standard deviation of page length for all mathematics textbooks is known to be 55. Part One: Assuming that...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT