Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在SQL(Oracle)字段之间进行行比较?_Sql_Oracle_Select_Compare - Fatal编程技术网

如何在SQL(Oracle)字段之间进行行比较?

如何在SQL(Oracle)字段之间进行行比较?,sql,oracle,select,compare,Sql,Oracle,Select,Compare,以下表为例: ------------------------- | time | start_time| ------------------------- | 50 | 80 | | 20 | 72 | | 45 | 30 | ------------------------- 我想要一个查询,返回时间小于相应行中给定的开始时间的所有行,此查询应返回: ----------------------

以下表为例:

-------------------------
| time      | start_time|
-------------------------
|  50       | 80        |
|  20       | 72        |
|  45       | 30        |
-------------------------
我想要一个查询,返回时间小于相应行中给定的开始时间的所有行,此查询应返回:

-------------------------
| time      | start_time|
-------------------------
|  50       | 80        |
|  20       | 72        |
-------------------------

假设两列都是数字,您可以尝试此操作。

如果您想将标量与集合进行比较。您可以使用任意或所有关键字。但我不确定你是否问过这件事


谢谢接线员@Alex.会怎么做。。我不确定我是否明白你的意思?时间和开始时间并没有相同的行数?我只是对它的行为感到好奇,它只会是你们提到的任何一种情况。我现在想不出任何一方的条目数不匹配的情况。例如,如果第二方是使用子查询获得的。这不是我所要求的,但这对了解谢谢很有用。
select *
from tablename
where time < start_time
select * from temp_table where 
time < any (select start_time from temp_table)

select * from temp_table where 
time < all (select start_time from temp_table)