我有这个结果集:
select a.id, a.categoria from Articolo a
where novita = 1
order by a.categoria, newid()
id categoria
----------- -----------
3 4
11 4
1 4
12 5
13 5
4 6
我会从每个不同的类别中获得第一个产品(以随机顺序):
id categoria
----------- -----------
3 4
12 5
4 6
理想情况下像
select FIRST(a.id), a.categoria from Articolo a
where novita = 1
order by a.categoria, newid()
有任何想法吗?