You are on page 1of 3

Relational Databases ASSIGNMENT – 2

Name: Kapila Ravichandran


Student ID: 8918716
Section: 2

1. Return the product ID, product name, list price, size, unit measure name, the subcategory name
and the product’s model name. Filter your result to include only the products that are not in the
company inventory. Use alias for the table.

SELECT p.ProductID, p.Name as 'Product Name', p.ListPrice, p.size,um.Name as 'Unit Measure Name',

sc.Name as 'Subcategory Name',pm.Name as "Model Name"

FROM [Production].[Product] p

JOIN [Production].[UnitMeasure] um

ON p.SizeUnitMeasureCode = um.UnitMeasureCode

JOIN [Production].[ProductSubcategory] sc

ON sc.ProductSubcategoryID = p.ProductSubcategoryID

JOIN [Production].[ProductModel] pm

ON pm.ProductModelID = p.ProductModelID

LEFT JOIN [Production].[ProductInventory] i

ON p.ProductID = i.ProductID

WHERE i.ProductID IS NULL;


2. The company raised the price list of some of her products. Write a query to show the details of
these products.

SELECT DISTINCT a.ProductID,a.Name, a.ListPrice AS 'Raised Price'

FROM [Production].[Product] a

JOIN [Production].[ProductListPriceHistory] b

ON a.ProductID = b.ProductID

WHERE a.ListPrice > b.ListPrice

3. Write a query to show products with no review.

SELECT *

FROM [Production].[Product]

WHERE [ProductID] NOT IN (SELECT [ProductID]

FROM [Production].[ProductReview])

4. Write a query to show products with same price. Include only products with a list price higher
than 100 or with Reorder points greater than 500.

SELECT a.[ProductID],a.ListPrice,b.ProductID,b.ListPrice

FROM [Production].[Product] a
JOIN [Production].[Product] b

ON a.[ListPrice] = b.[ListPrice]

WHERE a.[ProductID] != b.[ProductID]

AND (a.[ListPrice] > 100 OR a.[ReorderPoint] > 500)

You might also like