现在有一个表 表名为info我现在想做分页
当前的语句是这个样子的select top 30 * from info where id not in(select top 30 id from info)and id is not null这个语句是没有问题 但是我想排序一下 让先发帖的人在最上面 我用了order by fbtime desc 但是由于我现在用了top 30 所以排序完全的乱了 请大家帮个忙 这个sql语句应该怎么排序
当前的语句是这个样子的select top 30 * from info where id not in(select top 30 id from info)and id is not null这个语句是没有问题 但是我想排序一下 让先发帖的人在最上面 我用了order by fbtime desc 但是由于我现在用了top 30 所以排序完全的乱了 请大家帮个忙 这个sql语句应该怎么排序
select top 30 * from info where id not in(select top 30 id from info)and id is not null
) t order by fbtime desc
from
(
select top 30 * from info where id not in(select top 30 id from info)and id is not null
) t
order by fbtime desc
from
(
select top 30 * from info where id not in(select top 30 id from info) and id is not null
) t
order by fbtime desc
order by 字段
][/code]
select top 30 * from info where id not in(select top 30 id from info)and id is not null
order by 字段 desc
(
select top 30 * from info where id not in(select top 30 id from info)and id is not null
) t
order by fbtime desc
--sql2000
select * from
(
select *,Rn = (select count(1) from info where fbtime < a.fbtime)
from fbtime a
)t
where Rn between 40 and 60
order by rn
---sql 2005
select * from
(
select *,Rn = row_number() over (order by fbtime desc)
from fbtime a
)t
where Rn between 40 and 60
order by rn
我知道这样可以排序 但是我的意思是 如何让info这个表的数据在查询之前就排序好 也就是说select top 30 * from (select * from info order by fbtime desc)大家都误会了 可能是我表达的不好 小弟刚学 不好意思了
(
select *,row_numner() over(order by fbtime desc) rank from info
) T where rank<30
select
top 30
*
from
info
where
id not in(select top 30 id from info order by id)
and
id is not null
order by
fbtime desc
select top 30 * from (select * from info order by fbtime desc)
--select top 30 * from info order by fbtime desc
select top 30 * from (select top 100 percent * from info order by fbtime desc) t这样?
select top 30 * from info order by fbtime desc
public class readPro
{
public static void main(String[] args) throws IOException
{
Properties pro = new Properties();
FileInputStream fis = new FileInputStream("pro.properties");
pro.load(fis);
}}
Private Sub TmSendStatusRequest_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles TmSendStatusRequest.Elapsed
TmSendStatusRequest.Stop()
Dim ReturnValue As Boolean = False
Try
If (IsConnected = True) Then
ReturnValue = StatusRequest()
Exit Try
End If
Catch ex As Exception
EventLog.WriteEntry("PVGAFDS\TmSendStatusRequest_Elapsed", ex.Message.ToString() + Constants.vbCrLf + ex.StackTrace.ToString(), EventLogEntryType.Error)
Finally
End Try
TmSendStatusRequest.Start()
End Sub