【发布时间】:2018-03-25 22:30:19
【问题描述】:
我试图找出column5 数据大于column6 的时刻。以下命令适用于我在一个表中的结果
SELECT * FROM table1 WHERE column5 > column6;
但我想使用相同的条件column5 > column6 查询其他表的返回值,并且仍然选择全部,因为某些列提供了额外的相关信息和参考。例如,像
SELECT * FROM table1, table2 WHERE column5 > column6;
但我从一个模棱两可的命名表 column5 中抱怨错误...我将命令切换到类似
SELECT * FROM table1, table2 WHERE table1.column5 > table1.column6 AND table2.column5 > table2.column6;
上述命令不会产生错误,但查询返回空结果。我也尝试过这样的 INNER JOIN 命令
SELECT * FROM table1 INNER JOIN table2 ON table1.seconds = table2.seconds AND table1.column5 > table1.column6 AND table2.column5 > table2.column6;
这会产生与第一个命令类似的结果,但查询结果来自 table1 的所有行,该运算符有条件地在同一行中重复两次,但 table2 结果未显示。
还有其他方法可以实现吗?我的大多数尝试都没有返回预期的结果。同样,我只是希望我的查询产生多个表的 rowid WHERE *.column5 > *.column6
.sql file of the database pasted on codeshare.io to provide sample-data to this problem
把样本数据放在这里:
Table1:
Column5
"139062.6"
"115080"
"279718.5"
"106184"
"109483"
"152253"
"159030.3333"
"144092.5"
"154913.8333"
"52166.83333"
"18257.5"
"8907"
Column6
"224340.8"
"154723.6667"
"202486.8333"
"107184.8333"
"110674"
"257038.6667"
"151057"
"190702.6667"
"229714"
"37816.16667"
"18061.83333"
"6606.666667"
Table2:
Column5
"7544.6"
"10165.16667"
"11574.16667"
"9400.833333"
"11421.5"
"11368.5"
"11925.83333"
"9108.833333"
"8276.666667"
"8650.5"
"14998.16667"
"16229.83333"
Column6
"10109"
"14526.83333"
"12070.66667"
"7819.333333"
"9247.833333"
"7201.833333"
"8166.833333"
"4928"
"9135.5"
"9666.166667"
"8201.166667"
"10186"
Expected Result "WHERE column5 > column6" on table 1 and 2:
TABLE 1
Column5
"279718.5"
"159030.3333"
"52166.83333"
"18257.5"
"8907"
Column6
"202486.8333"
"151057"
"37816.16667"
"18061.83333"
"6606.666667"
TABLE 2
Column5
"9400.833333"
"11421.5"
"11368.5"
"11925.83333"
"9108.833333"
"14998.16667"
"16229.83333"
Column6
"7819.333333"
"9247.833333"
"7201.833333"
"8166.833333"
"4928"
"8201.166667"
"10186"
【问题讨论】:
-
请提供样本数据和预期结果。
-
我用底部的示例数据链接更新了问题。请忽略表 1。查询条件 WHERE column5 > column6 的预期结果应该类似于 "00:00:10-00:00:15" "812367.8333" "381901.6667" "188617.8333" "279718.5" "202486.8333" "207844.5" "199836" " 95699.83333""""""00:00:10-00:00:15""736087.5""142037.5""18376.16667""13577.83333""11524.66667""13789""6587.833333""5084.8333333
-
我们无法读心。还请将示例数据放在 table1 和 table2 上,以及结果的样子。我也打不开你的链接。它说“容量过剩”。将您的示例数据和预期结果粘贴到这篇文章中。