question

kpc1999kpc avatar image
kpc1999kpc asked

Simple average selling price and the number of transactions query

Hi, I need to make a query:

A statement containing the average selling price and the number of transactions for each type of product. Order the results in descending order by average price.

Here is how I print number of transactions for specific type of product (and their names at beggining):

SELECT productCode, COUNT(*)

FROM orderdetails

GROUP BY productCode

Here is table:

To count average selling price: For specific product type: for each product appearance:

(SUM(quantityOrdered * priceEach))/(quantityOrdered * number of transactions)

But I don't know how to count this part in SQL and show it... Can you help?

query
2021-04-04-2.png (33.0 KiB)
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.