sql use cte for multiple queries