Q:

From the following table, write a SQL query to compute the average price for unique companies. Return average price and company id

0

From the following table, write a SQL query to compute the average price for unique companies. Return average price and company id.

Sample table: item_mast

 PRO_ID PRO_NAME                       PRO_PRICE    PRO_COM
------- ------------------------- -------------- ----------
    101 Mother Board                    3200.00         15
    102 Key Board                        450.00         16
    103 ZIP drive                        250.00         14
    104 Speaker                          550.00         16
    105 Monitor                         5000.00         11
    106 DVD drive                        900.00         12
    107 CD drive                         800.00         12
    108 Printer                         2600.00         13
    109 Refill cartridge                 350.00         13
    110 Mouse                            250.00         12

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

SELECT AVG(pro_price) AS "Average Price", 
       pro_com AS "Company ID"
    FROM item_mast
GROUP BY pro_com;

Output of the Query:

Average Price			Company ID
250.0000000000000000		14
650.0000000000000000		12
3200.0000000000000000		15
5000.0000000000000000		11
1475.0000000000000000		13
500.0000000000000000		16

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now