0

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.

trans

here is the code I tried:

import duckdb
con = duckdb.connect(database=':memory:')

con.execute("""
-- 
select member_id, AVG(datediff(minute, order_date, payment_date)) as AverageTime
from trans
where purchase_succesfull = 'Yes'
group by member_id; 
""").df()

the code doesn't work, with the error Referenced column "minute" not found in FROM clause!.

So how to find the average time (in minutes) it takes users to make payment of their orders without any error?
It would be extremely helpful if someone could offer some advice.

Duta
  • 1
  • 1
    Not a duckdb user, but does minute need single quotes when using datediff? datediff('minute', start, end) – Isolated Jun 08 '22 at 16:50
  • 1
    Looks like you're right Isolated: https://duckdb.org/docs/sql/functions/date You should post that as an answer.. – Jim Jimson Jun 08 '22 at 16:51

0 Answers0