求一简单的SQL语句.各位来看看.
我想让state=9的值不按时间排,其它的时间排。如何写/
(select top 40 post_state,post_sendtime from UV_POSTLIST where post_state=9 or post_state=7
union
select top 40 post_state,post_sendtime from UV_POSTLIST where post_state!=9 or post_state!=7) order by POST_SENDTIME desc
并不能实现。。。
各位有什么好办法?
------解决方案--------------------order by 写在里面.
------解决方案--------------------select top 40 post_state,post_sendtime from UV_POSTLIST where post_state=9 or post_state=7
union
select top 40 post_state,post_sendtime from UV_POSTLIST where post_state!=9 or post_state <> 7 order by POST_SENDTIME desc
------解决方案--------------------(select top 40 post_state,post_sendtime from UV_POSTLIST where post_state=9 or post_state=7
union
select top 40 post_state,post_sendtime from UV_POSTLIST where post_state!=9 and post_state!=7) order by POST_SENDTIME desc
------解决方案--------------------select top 40 post_state,post_sendtime from UV_POSTLIST where post_state=9 or post_state=7
union
select top 40 post_state,post_sendtime from UV_POSTLIST where post_state!=9 or post_state!=7
order by POST_SENDTIME desc
------解决方案-------------------- select top 40 post_state,post_sendtime from UV_POSTLIST where post_state=9 or post_state=7
order by
case when post_state=9
then 'POST_SENDTIME desc ' end
------解决方案--------------------intString()的方法不错.
------解决方案-------------------- post_state=9 or post_state=7 (1)
post_state!=9 or post_state!=7 (2)
(1)的相反的条件因该是post_state!=9 and post_state!=7而不是(2)
我不知道我想的是不是你想要的
------解决方案--------------------我也是这么想的 存储过程
------解决方案--------------------JFJF!
------解决方案--------------------select * from (
select * from UV_POSTLIST where post_state=9
)
union
select * from (
select * from UV_POSTLIST where post_state!=9
order by POST_SENDTIME desc
)