作业帮 > 综合 > 作业

select max(account_id ) from(select top 5 account_id from ac

来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/09/20 16:26:45
select max(account_id ) from(select top 5 account_id from account)子查询没起作用为什么?
select max(account_id ) from(select top 5 account_id from ac
我是这样理解的:因为TOP 子句用于规定要返回的记录的数目,作用于整张表,例如SELECT TOP 50 PERCENT ,只是显示整张表的一半数目,后台数据库处理还是一张表,前台查询的返回结果是不同于临时表.所以虽然你查询出前五条,但是后台数据库处理max还是作用于整张account表 .所以得到的值是整张account表中account_id的最大值.select max(account_id) from account where account_id in (select top 5 account_id from account)