How summarize loop data and split by different condition by page

question

I want to query the database using pagination, then separate and count the data. Currently, I can only count one condition, and I am unable to obtain the other using a node. If I add a summarize node after the switch node, it only captures the result of a single execution.

Please share your workflow

Share the output returned by the last node

summarize1 get the right result but switch -0 output , I can’t summarize
[
{
“count_id”: 29
}
]


the summarize2 result, I can’t aggrate, how can I statistic the result

Information on your n8n setup

  • n8n version: 1.99.1
  • Database (postgress):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker):
  • Operating system:wsl

(post deleted by author)

hello @zhuliangxuan

try this one

thanks,now switch -1 result is right 。 but switch -0 in 3 different run result, how can I bring the three result sets together?

you shouldn’t break the loop this way. The flow will act quite unpredictable. What are you trying to achieve? You can build a filter within the Postgres node without the overcomplexity with the Loop and switch nodes.

general way of working with the Loop node - every branch within the loop should link back to the loop, so it will go to the done branch and combine the data from each run.

1 Like

yes, I should use other methods to achieve this, such as finding in a loop first, and then using the switch node to distinguish after the loop ends