SQL
- 1 ответ
- 0 вопросов
1
Вклад в тег
select CategoryId,max(id_min_value),max(id_max_value)
from
(select CategoryId,
case when ItemValue=min(ItemValue) over (partition by CategoryId) then ItemId end as id_min_value,
case when ItemValue=max(ItemValue) over (partition by CategoryId) then ItemId end as id_max_value
from Items) Items
group by CategoryId