[英]SQL Select one column only with distinct on another column
From this list:从这个列表中:
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
I would like only the 1st Id (to use for a cursor) on a distinct Material Result expected:我只想在预期的不同材料结果上使用第一个 ID(用于光标):
Id
5
114
250
395
176
231
380
192
Any suggestion?有什么建议吗?
Use min()
?使用min()
?
select min(id)
from t
group by material;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.