sql效率
1、select top 6 * from [jslm].[dbo].[Company_Info] WHERE c_ID NOT IN(SELECT TOP 4 c_ID FROM [jslm].[dbo].[Company_Info] order by c_ID) order by c_ID
2、select top 6 *
from [jslm].[dbo].[Company_Info]
where c_ID> (select max(c_ID) from (select top 4 c_ID from [jslm].[dbo].[Company_Info] order by c_ID) a)
order by c_ID
select max(c_ID) from 范围(内含有c_ID) 查找最大是c_ID
83万数据 第一种 要4秒 第二种要3秒
3、SQL MAX()后取其对应的一条记录
SELECT
S.NameGroup
,sName=(SELECT sName from @TMP WHERE NameGroup = S.NameGroup AND Number = MAX(S.Number))
,max(s.Nmuber) as Number
from #TMP S
group by S.NameGroup