Skip to content

Commit 03d5419

Browse files
authored
Create SQL Exercises: Display the names of the company whose products have an average price larger than or equal to Rs.350
1 parent 013c5ca commit 03d5419

1 file changed

+37
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
https://www.w3resource.com/sql-exercises/sql-joins-exercise-24.php
2+
3+
SQL JOINS: Exercise-24 with Solution
4+
From the following tables write a SQL query to calculate and find the average price of items of each company higher than or equal to Rs. 350. Return average value and company name.
5+
Sample table: company_mast
6+
COM_ID COM_NAME
7+
------ -------------
8+
11 Samsung
9+
12 iBall
10+
13 Epsion
11+
14 Zebronics
12+
15 Asus
13+
16 Frontech
14+
15+
Sample table: item_mast
16+
PRO_ID PRO_NAME PRO_PRICE PRO_COM
17+
------- ------------------------- -------------- ----------
18+
101 Mother Board 3200.00 15
19+
102 Key Board 450.00 16
20+
103 ZIP drive 250.00 14
21+
104 Speaker 550.00 16
22+
105 Monitor 5000.00 11
23+
106 DVD drive 900.00 12
24+
107 CD drive 800.00 12
25+
108 Printer 2600.00 13
26+
109 Refill cartridge 350.00 13
27+
110 Mouse 250.00 12
28+
29+
30+
31+
select avg(b.pro_price), a.com_name
32+
from company_mast as a
33+
join item_mast as b on a.com_id=b.pro_com
34+
group by a.com_name
35+
having avg(b.pro_price) >= 350
36+
order by avg(b.pro_price) desc
37+
;

0 commit comments

Comments
 (0)