Each CTE returns two values: I divide one by the other and I get a percentage.
The query works, but I don't think I need a cte or variables for this.
So how can this look more elegant?
Thanks.
;with cte2 as ( select FIELD1 From TABLE1 where FIELD2 not like 'ABC%' and FIELD1 not in ( select FIELD1 From TABLE1 where FIELD2 like 'ABC%' group by FIELD1 ) group by FIELD1 ) select count(*) from cte2 ;with cte as ( select FIELD1 From TABLE1 group by FIELD1 ) select count(*) from cte
VM