Body: <p>My section has two numeric fields, <code>lorem</code> and <code>ipsum</code>. It's possible for users to enter any integer they want into these two fields.</p>
  
  <p><strong>I want to grab all results where <code>lorem</code> is greater than <code>ipsum</code>.</strong></p>
  
  <p>Here's my starting point...</p>
  
  <pre><code>{% set results = craft.entries.section('foo').limit(3) %}
  </code></pre>
  
  <p>How would I alter the above Element Criteria Model to only retrieve entries where the value of <code>lorem</code> is greater than the value of <code>ipsum</code>?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-05-10T19:17:41.063Z
Comments.Text: Pretty sure you're going to have to get your hands dirty to achieve this. Maybe do a raw query to return all of the record IDs which meet your lorem / ipsum criterion, and then use those IDs in the main ElementCriteriaModel query, so you still get Craft to do the heavy lifting.
Comments.UserDisplayName: Stephen Lewis
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-05-10T19:19:08.207Z
Comments.Text: I would say create a variable in a plugin to handle this, have it return the find() call.
Comments.UserDisplayName: Rick Kukiela
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-05-10T19:28:14.270Z
Comments.Text: Crazy... I think you guys are right, I'll need to dig into a plugin to make this work. I'm a bit surprised there isn't a simpler solution. Thanks Stephen & SublymeRick!
Comments.UserDisplayName: Lindsey D
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-05-10T21:05:52.843Z
Comments.Text: @LindseyD, you should post your Slack solution in here. I'm sure this will help some people.
Comments.UserDisplayName: Max Strebel
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-05-10T21:07:38.967Z
Comments.Text: @LazyPirate I haven't actually tried it yet, so I'm not sure if/how it works. But I'll try to post back when I do!
Comments.UserDisplayName: Lindsey D
Tags: <templating><elementcriteriamodel><comparisons>
Title: When constructing an ECM, is it possible to compare two values?
ThreadText: # When constructing an ECM, is it possible to compare two values?
  
  (Asked by: username_0 on 2017-05-10)
  
  My section has two numeric fields, `lorem` and `ipsum`. It's possible for users to enter any integer they want into these two fields.
  
  **I want to grab all results where `lorem` is greater than `ipsum`.**
  
  Here's my starting point...
  
  ```
  {% set results = craft.entries.section('foo').limit(3) %}
  
  ```
  
  How would I alter the above Element Criteria Model to only retrieve entries where the value of `lorem` is greater than the value of `ipsum`?
  
  **Tags:** templating, elementcriteriamodel, comparisons
  
  > **Comments:**
  > **username_1**: Pretty sure you're going to have to get your hands dirty to achieve this. Maybe do a raw query to return all of the record IDs which meet your lorem / ipsum criterion, and then use those IDs in the main ElementCriteriaModel query, so you still get Craft to do the heavy lifting.  
  > **username_2**: I would say create a variable in a plugin to handle this, have it return the find() call.  
  > **username_0**: Crazy... I think you guys are right, I'll need to dig into a plugin to make this work. I'm a bit surprised there isn't a simpler solution. Thanks username_1 & SublymeRick!  
  > **username_3**: @username_0, you should post your Slack solution in here. I'm sure this will help some people.  
  > **username_0**: @LazyPirate I haven't actually tried it yet, so I'm not sure if/how it works. But I'll try to post back when I do!  
  
  ---
  
  ## 0 answers
  
  