Lets say we have following table:
Employee
ID Name Sick_Leaves Casual_Leaves
1 John 4 8
2 Nancy 5 2
3 Matthew 2 9
Now if I want to get a list of all the Employess who have taken more sick leaves than casual, its straight forward in SQL:
Select * from Employee Where Sick_Leaves > Casual_Leave
Now considering that I have a Rails Active Record Model class defined for Employee, how can I execute the same query using model class itself ? I am getting stuck in how to define the WHERE clause. If it had been Sick_Leaves > 5 (or some fixed number), then its simple, but what now when we want to compare two columns itself ?
Any help will be appreciated.