Sql语句 - MS-SQL Server / 疑难问题
写一个SQl语句得到一个表的最后一行的值?
SQL code:
select top 1 * from tb order by id desc
数据没规律?1楼的语句除非你id是自增列。否则不好处理。
SQL code:
select top 1 * from tb order by id desc
如果有id的话。
应该把你这个表的特征说出来,比如有什么比较特殊的字段。。比如自增列等。
如果主键没啥规律,就生成个辅助列:
select id=identity(1,1),* into # from 表名
select top 1 * from # order by id desc
人家没说有
也没说没有啊
我就当有处理啊
相关问答:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jas ......
现在有一个部门表dept(部门名称,部门号。。)有一个人员表emp(姓名,人员编号,职位,薪资,部门)
emp表中的内容是这样的:
a 1 工程师 3000 软件部
b 2 普通员工 2000 硬件部
c 3 工程师 4000 硬件部
d ......
A表 有两个字段
id 唯一数字域
InfoTxt text 类型
我现在要把 id 不是14 的所有 InfoTxt字段 文本后面 都加上 'aaa'
按下面执行下来 只有表最后一行加上了 'aaa' ......
在Access的查询中执行下面的语句,无效,提示期待select ,updata ,...
CreateTble C=Answer N="回帖表"
(
C=ID T="INTEGER" P=No M=No N="编号" Z=false,
C=Ques ......