In my DB I have two tables Items(Id, ..., ToatlViews int) and ItemViews (id, ItemId, Timestamp)
In ItemViews table I store all views of an item as they come to the s
Same but different:
declare @productId int = 24;
declare @classificationTypeId int = 86;
update s
set CounterByProductAndClassificationType = row_num
from Samples s
join
(
select row_number() over (order by (select Id)) row_num, Id
from Samples
where
ProductId = @productId and
ClassificationTypeId = @classificationTypeId
) s_row on s.Id = s_row.Id