In addition to subquery, we can use Common Table Expression (CTE) with the same result and also neater code.

cte_table  is unlike #temp in which you can recall anytime. With cte_table , the query that refers to it must be run at the same time as its creation. But… it does look better than subquery.