Create dynamic_query