我是psql的新手,想知道如何完成特定的查询结果。
这是我当前的查询:
select contact_name, date_created, edocs_signed_date, leadsource, extract(day from edocs_signed_date - date_created) as turntime
from turntime_on_closed_deals;
我正在使用提取来创建营业时间列,该列将告诉我们每个人从他们在系统中创建之日起与我们签约的时间。
如何获取最近7天该平均营业时间列的数量?最后30个?
日期范围将基于edocs_signed_date列。
以下是表中前几条记录的示例:
contact_name date_created edocs_signed_date leadsource turntime
"Name1" "2020-08-19 13:06:48" "2020-08-20 00:00:00" "LeadSource1" 0
"Name2" "2020-06-16 17:27:56" "2020-06-18 00:00:00" "LeadSource2" 1
"Name3" "2020-07-01 11:25:04" "2020-07-09 00:00:00" "LeadSource2" 7
"Name4" "2020-09-05 16:48:36" "2020-09-10 00:00:00" "LeadSource2" 4
"Name5" "2020-08-20 11:08:44" "2020-08-20 00:00:00" "LeadSource1" 0
"Name6" "2020-06-27 17:04:01" "2020-07-13 00:00:00" "LeadSource3" 15
"Name7" "2020-07-08 11:21:36" "2020-07-20 00:00:00" "LeadSource2" 11
感谢您的帮助!