@Tokbanov you might want to check out this thread and the solution
This is a way to first use a temporary table first: