Quantcast
Channel: SQL.ru: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 7251

выявить товары которые снизились, как сделать ее правильно ?

$
0
0
select ProductID, StandardCost from Production.ProductCostHistory
inner join ProductId on Production.ProductCostHistory.p = ProductID.p
join ( select p.ProductID, max(StartDate) as StartDate from Production.ProductCostHistory
where (EndDate is NULL or EndDate > getdate()) group by ProductID ) t on t.ProductID = p.ProductID
and t.StartDate = p.StartDate
order by p.ProductID

Viewing all articles
Browse latest Browse all 7251

Trending Articles