select max(account_id ) from(select top 5 account_id from account)子查询没起作用为什么?

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/29 20:33:39
select max(account_id ) from(select top 5 account_id from account)子查询没起作用为什么?

select max(account_id ) from(select top 5 account_id from account)子查询没起作用为什么?
select max(account_id ) from(select top 5 account_id from account)子查询没起作用为什么?

select max(account_id ) from(select top 5 account_id from account)子查询没起作用为什么?
我是这样理解的:因为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)