I am trying to make this automated with a loop where I define an beginning and ending time period @t_begin , @t_end starting from 0 to 24 for example. CURRENTLY, I am putting all these codes one by one, and for ending t=60 for example, I need to copy and paste 60 subqueries. I am trying to make this automated with a loop