Quantcast
Channel: User BobbyShaftoe - Stack Overflow
Viewing all articles
Browse latest Browse all 45

Answer by BobbyShaftoe for Help creating the necessary TSQL for this basic requirement

$
0
0

There are so many ways to do this and depends heavily on your schema. This is one way. Obviously, this is not a complete schema.

ProductCategory(Id, CategoryName)

Product(Id, ProductCategoryId, ProductName)

Store(Id, StoreName)

Customer(Id, FirstName, LastName)

Order(Id, StoreId, CustomerId, Date)

OrderDetail(Id, OrderId, ProductId)

SELECT Product.ProductName, ProductCategory.CategoryNameFROM Product INNER JOIN ProductCategory ON Product.CategoryId = ProductCategoryId INNER JOIN OrderDetail ON OrderDetail.ProductId = Product.Id INNER JOIN Order ON Order.Id = OrderDetail.OrderIdINNER JOIN Customer ON Order.CustomerId = Customer.IdWHERE Customer.FirstName = 'Monica'ORDER BY ProductCategory.CategoryName

Viewing all articles
Browse latest Browse all 45

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>