Z
Z
Zunga2019-10-14 14:06:38
PostgreSQL
Zunga, 2019-10-14 14:06:38

Nested sql query with filtering by date?

Hello everyone, I would like to ask you to help me with this request.
There is a client with which tasks are associated (by client id ), tasks can be both open and closed
Romashka LLC {
name closing date
Task # 1 2019-10-01
Task # 2 null
Task # 3 2019-07-01
}
Needed display a list of all clients whose last task has been closed for more than 60 days.
Here is a query:

select DISTINCT AC.name,ACTIV.name,(extract(day from now() - ACTIV.datefinish)) from sys_accounts AC RIGHT JOIN sys_activities ACTIV ON ACTIV.account_guid=AC.guid WHERE (extract(day from now() - ACTIV .datefinish))>60

But how to count days in it exactly from the last closed task in each specific client?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question