1. Find models and prices of all products manufacured by ‘B’

Find models and prices of all products manufacured by ‘B’. There are two ways to get this data:
 
1. SELECT DISTINCT product.model, COALESCE (laptop.price, pc.price, printer.price, 0) AS Expr1
FROM         product LEFT OUTER JOIN
                      laptop ON laptop.model = product.model LEFT OUTER JOIN
                      pc ON pc.model = product.model LEFT OUTER JOIN
                      printer ON printer.model = product.model
WHERE     (product.maker = ‘B’)
 
 
2. SELECT     product.model, type.price
FROM         product INNER JOIN
                          (SELECT     model, price
                            FROM          laptop
                            UNION
                            SELECT     model, price
                            FROM         pc
                            UNION
                            SELECT     model, price
                            FROM         printer) AS type ON product.model = type.model
WHERE     (product.maker = ‘B’)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s