易截截图软件、单文件、免安装、纯绿色、仅160KB

求一SQL语句 - MS-SQL Server / 疑难问题

在SQL数据库中,我想要查询当前数据表中的最后10条数据
其SQL语句该如何写、
  求大家帮帮我啊........
给点儿数据和结构吧...

SQL code:
--假设ID是自增列
SELECT TOP 10 *
from TB
ORDER BY ID DESC


有排序字段直接
select top 10 * from tb order by 排序字段 desc

没有的话 需要自己去加个排序字段

引用
在SQL数据库中,我想要查询当前数据表中的最后10条数据
其SQL语句该如何写、
求大家帮帮我啊........

select top 10 * from tb order by id desc

引用
引用楼主 kun_kun_zheng 的回复:
在SQL数据库中,我想要查询当前数据表中的最后10条数据
其SQL语句该如何写、
求大家帮帮我啊........

select top 10 * from tb order by id desc


UP...

select identity(int,1,1) myid,* into #t
select top 10 * from #t order by myid desc


SQL code:
;with t as
(
select rn=row_number()over(order by getdate()),--没ID的情况
from tb
)
select * from tb order by rn desc


SQL code:
;with t as
(
select rn=row_number()over(ord


相关问答:

sqlserver错误 - MS-SQL Server / 疑难问题

sqlserver2005 建立的数据库,与手持pda传输数据,最近突然出现无法传递数据的问题,pda端提示的错误时outofmemoryexception,但是pda上面的容量没有问题,
sqlserver的日子上的错误如下:
日期 2010-1-25 14:45: ......

求一SQL - MS-SQL Server / 基础类

tab1 字段:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 字段:goodsid,goodskind(商品类型)
tab3 字段:goodskind(商品类型),kindname
结果:
得到商品类型在一段时间 ......

请教SQLSERVER的两个问题 - MS-SQL Server / 疑难问题

1。怎样使xp_cmdshell能完整输出超过255个字符的字符串。
2。select 时,检索速度是与from后的 TABLE顺序有关,还是与where条件的顺序有关(TABLE数据多少 )
在系统属性设定里有个选项,可以修改单字段输出字数限制. ......

请教SQL语句查询问题? - MS-SQL Server / 基础类

我想查询出每天数据的最大的一个值。表的格式如下
表名: hisdata
字段 编号 值 状态 时间  
  Id value state dattime  
  101 32.3 0 ......

SQL server分解XML - MS-SQL Server / 应用实例

下面是XML初始文件内容
XML code:
<upd:Update xmlns:lar="http://schemas.microsoft.com/msus/2002/12/LogicalApplicabilityRules" xmlns:cmd="http://schemas.microsoft.com/msus/2002/12/Up ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号