SQL Server node execute query only return 1 item

Hi All,

It can only return 1 item.
How can I get the following result:
guestId Total
1 20000
2 20000



Hi @anderson.wong

What you want to do here is a bit unclear to me, as you are getting the values from the SQL query. The amount that is going into this node has no influence on that.
for SQL it only runs for the first item, that is correct. So what you could do is use the itemlists node to aggregate the guestid’s and then alter the query a bit to take an array and select the guestids that way.

or use split in batches to create a loop (Looping - n8n Documentation)

1 Like

This will work but for this input would result in a duplicate item for guestid 2

That it would as it is defined twice.

I can do the remove duplicates so that the input has only guest1 and guest2, but how can I do the aggregation the 2 guests.
I don’t want to split in batches, because that way can only has 1 item output each loop. I would like to get the 2 guests aggragation result in the output.

What about using the split in batches (as recommended) then use a code node to merge the execution data?

This should works for me. Thank you.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.