titusmagnus
titusmagnus

Reputation: 2082

Find rows where one field is greater than another one

My SQL is a bit rusty. 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. Any ideas?

Thanks for the help!

Upvotes: 6

Views: 21571

Answers (2)

Tombatron
Tombatron

Reputation: 1347

Specify the desired columns between the SELECT and FROM and your predicates after the 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.

Upvotes: 14

Jafar Kofahi
Jafar Kofahi

Reputation: 763

Did you try

Select *
From table 
where CreatedAt < UpdatedAt

Upvotes: 3

Related Questions