Question: postgresql knowing that we have these following tables: beersdb=# select * from Frequents; drinker | bar --------------+------- Bill Jones | Joe's Bill Jones | Sue's

 postgresql knowing that we have these following tables: beersdb=# select *

postgresql knowing that we have these following tables:

beersdb=# select * from Frequents;

drinker | bar

--------------+-------

Bill Jones | Joe's

Bill Jones | Sue's

Kelly Arthur | Joe's

(3 rows)

beersdb=# select * from Likes;

drinker | beer

--------------+--------------

Bill Jones | Miller

Bill Jones | Michelob

Kelly Arthur | Anchor Steam

Fred | MGD

(4 rows)

beersdb=# select * from Drinkers;

name | addr | phone

--------------+----------------+------------------

Bill Jones | 180 Saint St. | 831-459-1812

Kelly Arthur | 180 Alto Pl. | 650-856-2002

Fred | 1234 Fifth St. | 831-426-1956

(3 rows)

beersdb=# select * from Bars;

name | addr | license

-------+----------------+---------

Joe's | 123 Any Street | B7462A

Sue's | 456 My Way | C5473S

(2 rows)

beersdb=# select * from Beers;

name | manf

--------------+----------------

Coors | Adolph Coors

Coors Lite | Adolph Coors

Miller | Miller Brewing

Miller Lite | Miller Brewing

MGD | Miller Brewing

Bud | Anheuser-Busch

Bud Lite | Anheuser-Busch

Michelob | Anheuser-Busch

Anchor Steam | Anchor Brewing

(9 rows)

beersdb=# select * from Sells;

bar | beer | price

-------+--------------+-------

Joe's | Coors | 2.5

Joe's | Bud | 2.5

Joe's | Bud Lite | 2.5

Joe's | Michelob | 2.5

Joe's | Anchor Steam | 3.5

Sue's | Coors | 2

Sue's | Miller | 2

(7 rows)

1) Write SQL code for the following queries (10 pts each): a) Find names and addresses of drinkers who frequent more than one bars. (Your query must be using HAVING) b) What is the average price of beer sold by Joe's'? c) How many bars sell a beer liked by 'Bill Jones' for less than 3.00? d) Find the names of the bars that sell 'Bud for the cheapest price (compared with other bars)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!