title: Query to find the average time (in minute) it takes users to make payment of their orders
body: <p>As seen below, I have a table called trans. I'm looking for the average time (in minutes) it takes users to pay for their orders in the table.</p>
  <p><a href="https://i.stack.imgur.com/QbJEP.png" rel="nofollow noreferrer">trans</a></p>
  <p>here is the code I tried:</p>
  <pre><code>import duckdb
  con = duckdb.connect(database=':memory:')
  </code></pre>
  <br>
  <pre><code>con.execute(&quot;&quot;&quot;
  -- 
  select member_id, AVG(datediff(minute, order_date, payment_date)) as AverageTime
  from trans
  where purchase_succesfull = 'Yes'
  group by member_id; 
  &quot;&quot;&quot;).df()
  </code></pre>
  <p>the code doesn't work, with the error <code>Referenced column &quot;minute&quot; not found in FROM clause!</code>.</p>
  <p>So how to find the average time (in minutes) it takes users to make payment of their orders without any error? <br>
  It would be extremely helpful if someone could offer some advice.</p>