title: Interval Keyword
body: <p>I am working on a question which has the schema as below:</p>
  <pre><code>user_id int
  created_at datetime
  number_of_comments int
  </code></pre>
  <p>and the question is, Return the total number of comments received for each user in the last 30 days. Assume today is 2020-02-10.</p>
  <p>I figured out that one way of doing this problem is:</p>
  <pre><code>SELECT 
      user_id, 
      sum(number_of_comments) as comments 
  FROM fb_comments_count
  WHERE created_at &gt;= '2020-02-10'::date - '30 day'::interval  
  AND created_at &lt;= '2020-02-10'::date  
  GROUP BY 1
  </code></pre>
  <p>but I am struggling understand the logic behind it. For example, what does this keyword INTERVAL is and how it helps? and how are we subtracting a date from an interval?</p>
  <p>I tried writing a small query:
  <code>select 30 * INTERVAL '1 day'</code>
  and it return a number which is 2592000.
  What is this number? Any help would be appreciated.</p>