18 | | select |
19 | | b.business_id, |
20 | | b.business_name, |
21 | | ( |
22 | | select |
23 | | avg(r.review_stars) |
24 | | from |
25 | | review r |
26 | | where |
27 | | r.business_id = b.business_id |
28 | | ) as business_avg_stars, |
29 | | c.category_name, |
30 | | a.address_city |
31 | | from |
32 | | business b |
33 | | join category c on |
34 | | b.category_id = c.category_id |
35 | | join address a on |
36 | | b.business_id = a.business_id |
| 18 | select |
| 19 | b.business_id, |
| 20 | b.business_name, |
| 21 | ( |
| 22 | select avg(r.review_stars) |
| 23 | from review r |
| 24 | where r.business_id = b.business_id |
| 25 | ) as business_avg_stars, |
| 26 | c.category_id, |
| 27 | c.category_name, |
| 28 | ( |
| 29 | select string_agg(a.address_city, '; ') as address_city |
| 30 | from address a |
| 31 | where a.business_id = b.business_id |
| 32 | ) as address_city |
| 33 | from business b |
| 34 | join category c on |
| 35 | b.category_id = c.category_id |
| 36 | order by b.business_name |