SQL Select 只有一列与另一列不同
SQL Select one column only with distinct on another column
来自这个列表:
Id Material
5 100% Alpaca
8 100% Alpaca
32 100% Alpaca
113 100% Alpaca
271 100% Alpaca
437 100% Alpaca
114 100% Alpaca (Baby Royal)
115 100% Alpaca (Baby Royal)
116 100% Alpaca (Baby Royal)
250 100% Alpaca (Baby)
395 100% Alpaca (Royal)
176 100% Alpaca (Super Fine)
231 100% Alpine Stone Sheep
329 100% Alpine Stone Sheep
330 100% Alpine Stone Sheep
380 100% Aluminum
192 100% Angora
193 100% Angora
194 100% Angora
我只想在不同的 Material 上使用第一个 ID(用于游标)
预期结果:
Id
5
114
250
395
176
231
380
192
有什么建议吗?
使用min()
?
select min(id)
from t
group by material;
来自这个列表:
Id Material
5 100% Alpaca
8 100% Alpaca
32 100% Alpaca
113 100% Alpaca
271 100% Alpaca
437 100% Alpaca
114 100% Alpaca (Baby Royal)
115 100% Alpaca (Baby Royal)
116 100% Alpaca (Baby Royal)
250 100% Alpaca (Baby)
395 100% Alpaca (Royal)
176 100% Alpaca (Super Fine)
231 100% Alpine Stone Sheep
329 100% Alpine Stone Sheep
330 100% Alpine Stone Sheep
380 100% Aluminum
192 100% Angora
193 100% Angora
194 100% Angora
我只想在不同的 Material 上使用第一个 ID(用于游标) 预期结果:
Id
5
114
250
395
176
231
380
192
有什么建议吗?
使用min()
?
select min(id)
from t
group by material;