0

i have lets say 100 items that can be brought from 100 stores,i need a query that will give list of items found with minimum rate when search with store's name,suppose i select store name X then it should return list of items where rate is cheapest in the market.

4

1 回答 1

0

你所说的“率”是什么意思?如果是价格,这是我的答案。

我假设您有以下表格:

存储(Id INT,标题 VARCHAR(100))

项目(Id INT、Title VARCHAR(100)、StoreId INT、价格 NUMERIC(19,2))

您的查询应如下所示:

SELECT i.Title, i.Price
FROM dbo.Item i
INNER JOIN dbo.Store s ON s.Id = i.StoreId
WHERE s.Title = 'Store name'
ORDER BY i.Price
于 2013-01-28T08:16:35.313 回答