易截截图软件、单文件、免安装、纯绿色、仅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


相关问答:

SQL如何优化问题 - MS-SQL Server / 疑难问题

今天做了一个存储过程   环境是SQL2000数据库  
大致如下
建立临时表
定义员工游标
        循环员工(属于1个公司)  
        ......

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

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

如何使用MySQL - MS-SQL Server / 基础类

刚刚接触MySQL,不知道该如何去查看数据,插入数据,创建数据库、表,用哪为前辈能指教一二?

MySQL 5.1参考手册

引用
兄弟你会结贴吗?
mysql 参考手册

baidu

MySQL官方文档 http://dev.mysql.com/doc ......

求一个SQL语句 - MS-SQL Server / 基础类

字段1,字段2.....字段N,Status,ParentID
1,Name1....test1,1,99
1,Name1....test1,3,99
1,Name2....test2,1,101
1,Name2....test2,3,101
1,Name3....test3,2,101
1,Name1....test1,4,101
想要的结果是:
1,Na ......

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

我想查询出每天数据的最大的一个值。表的格式如下
表名: hisdata
字段 编号 值 状态 时间  
  Id value state dattime  
  101 32.3 0 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号