I'm trying to run this subquery in alteryx design using Connect In-DB and Browse In-DB tool as follow:

my query is like that

I have used visual query builder to develop this subquery. Now the problem is when I run it, it takes 40 minutes to run and nothing shows up on the browser result window
I need guidance with this problem and how to optimize this workflow