日期:2014-05-18 浏览次数:20661 次
select top 3 NOTICENO,NT_TITLE,NT_CONTENT,USERNAME,ADDTTIME from NOTICES where DISPLAY=1 union --去掉两个查询的重复行,重复行显示一次 select top 3 NOTICENO,NT_TITLE,NT_CONTENT,USERNAME,ADDTTIME from NOTICES
------解决方案--------------------
select top 3 NOTICENO,NT_TITLE,NT_CONTENT,USERNAME,ADDTTIME from NOTICES ;with tmp as ( select top 3 NOTICENO,NT_TITLE,NT_CONTENT,USERNAME,ADDTTIME from NOTICES where DISPLAY=1 ) select NOTICENO,NT_TITLE,NT_CONTENT,USERNAME,ADDTTIME from tmp as a where a.NOTICENO not in (select top 3 NOTICENO from NOTICES) union all select top 3 NOTICENO,NT_TITLE,NT_CONTENT,USERNAME,ADDTTIME from NOTICES