简体   繁体   English

查找其中一个字段大于另一字段的行

[英]Find rows where one field is greater than another one

My SQL is a bit rusty. 我的SQL有点生锈。 I'm not been able to find a way to retrieve rows where one value is greater than the other one. 我无法找到一种方法来检索其中一个值大于另一个值的行。 For example, I have the following row: 例如,我有以下行:

{
    ROWID       1,
    CreatedAt   2013-08-03 10:10:23:344,
    UpdatedAt   2013-08-03 11:10:23:344,
}

I would like to perform the query 'select all rows where 'UpdatedAt' is greater than 'CreatedAt' and match rows such the one above. 我想执行查询“选择'UpdatedAt'大于'CreatedAt'的所有行,并匹配上述行。 Any ideas? 有任何想法吗?

Thanks for the help! 谢谢您的帮助!

Specify the desired columns between the SELECT and FROM and your predicates after the WHERE . SELECTFROM以及WHERE之后的谓词之间指定所需的列。

SELECT ROWID, CreatedAt, UpdatedAt FROM TableName WHERE UpdatedAt > CreateAt;

Remember with SQL that if all of the predicates in your query do not evaluate to True in some way, the row will not return. 请记住,使用SQL请注意,如果查询中的所有谓词都不以某种方式求值为True ,则该行将不会返回。

Did you try 你试过了吗

Select *
From table 
where CreatedAt < UpdatedAt

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Select 其中一个字段的计数大于一 - Select where count of one field is greater than one SQL - 获取一列比某个列大一定百分比的行 - SQL - get rows where one column is a certain percentage greater than another 如何查询一个字段大于另一个字段x天的记录? - How to query records where one field greater than another by x days? 仅在count(ID)大于1的行上使用聚合 - Use aggregation only on rows where count(ID) is greater than one SQL 查询 - 查找具有基数大于 1 的字段的记录 - SQL Query - Find records with field that has cardinality greater than one 如何在一个数据库表中查找其中一个字段的值与另一表中的值不同的行 - How to I find rows in one database table where a value of one field is NOT LIKE a value in another table MySQL 选择一行,其中一个字段小于前一条记录,一个字段大于 - MySQL select row where one field is less than the previous record and one field is greater MySQL-如何选择主键多次出现并且至少另一个字段匹配的行? - MySQL - how to select rows where a primary key occurs more than once AND at least one of another field matches? 查找一个字段的实例,其中另一个字段的对应值(应该是 1-1)具有多个值 - Find instances of a field where corresponding values in another, which should be 1-1, have more than one value SQL-Sqlite查询:获取一个数字大于另一个数字的字段,如果小于3且第一个数字完整,则始终为3 - SQL - Sqlite Query: obtain the fields where one number is greater than another, if less than 3 complete with the first, always 3
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM