排序结果而不使用order by子句 [英] sort results without use of order by clause

查看:387
本文介绍了排序结果而不使用order by子句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在面试中问了一个问题,排序结果没有使用order by子句和不使用像php的脚本。我足够google,但没有找到方法。是否有任何方法以这种方式排序结果。

I am asked a question in interview that sort result without using of order by clause and without using the script like php. I enough google it but did not find the way. Is there any method to sort results in this way. And it should be without using of any script like php etc.

推荐答案

你不能,至少不可靠。

某些SQL 实现可能按照主键或聚簇索引的顺序返回行,但SQL本身是返回任意有序集的关系代数,除非特别

Some SQL implementations may well return rows in the order of their primary keys or clustered indexes, but SQL itself is a relational algebra that returns arbitrarily ordered sets unless specifically told otherwise.

自从创建表之后,很有可能返回行的顺序取决于插入和删除活动。

There's a good chance that the order in which rows are returned may well depend on the insertion and deletion activity since the table was created.

我对这样的面试问题的回答是:

My answer to an interview question like that would be:


有什么理由我们不能在查询中使用order by?公司是如此艰难的钱,他们不能承受磁盘空间存储这些额外的几个字节的每个查询? 向我提出一个相关的问题: - )

Is there some sort of reason why we can't use 'order by' in our queries? Is the company so hard up for money that they cannot afford the disk space to store those extra few bytes for each query? Are you out of you goddamned mind? Ask me a question that's going to have some relevance :-)

这篇关于排序结果而不使用order by子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆