Use result from SQL query executed earlier

Hi,

I’m building a workflow that does the following:

  1. Select data using SQL
  2. Summarizes the data to a count of the result rows
  3. Check if the summary is more than 0 (basically makes sure there is a result)
  4. If there is result: insert result from step 1 and send 1 e-mail using the summary
  5. Always end with an HTTP call

Because the insert node uses the input from the IF node it doesn’t insert the data from de query. To get around this I think the query must run again. This is no problem for simple queries but some queries are more extensive and it would be great if this isn’t necessary.

At the moment I’m using the following workflow.

Any help to make this workflow more efficient would be greatly appriciated.

Hey @LBthomas hope all is good. Welcome to the community.

  1. instead of counting in summary you can check if {{ $json }} object is not empty directly in the If node.
  2. No need to re-query the DB
  3. to calculate inserted rows, aggregate the response and use the count in the email node.

Hi @jabbson,
Thanks for your quick response and the warm welcome.

I was clearly thinking way to complicated. This works great!

Glad I could help.