相同Id只加载一条数据
我想通过像同的E_Id只加载一条数据。该怎么做还请各位前辈指教,小弟在这谢过大家数据 --------------------编程问答-------------------- select Ed_Id, max(Ed_Name) as Ed_Name, Max(Ed_Content) as Ed_Context, ... from table groupby ed_Id --------------------编程问答-------------------- select * from tb where Ed_id in (select max(Ed_Id) form tb group by E_id) --------------------编程问答--------------------
select * from table where ed_id in (select min(ed_id) from ttt group by e_id)--------------------编程问答-------------------- 哈哈,跟楼上雷同了。。。 --------------------编程问答--------------------
select *
from
(
select *,rn=ROW_NUMBER() OVER(partition by E_id order by getdate()) from tb
)t
where rn=1
相同的E_id取第一条,利用ROW_NUMBER()生产行号,partition by 是按E_id分组,之所以用order by getdate() 表示默认当关排序
补充:.NET技术 , ASP.NET