日期:2014-05-18 浏览次数:20448 次
SELECT TOP 5 * FROM T ORDER BY NEWID()
------解决方案--------------------
select top 5 * from t as a where not exists(select 1 from t where Name=a.Name and ID<a.ID) order by newID() 或 select top 5 min(ID) as ID,Name from t group by Name order by newID()
------解决方案--------------------
随机取记录
大版写的SQL可能会出现相同Name的最大那一行永远也取不到吧