In often use in TSQL the following query :
SELECT COUNT(*), *
FROM CUSTOMER c
WHERE c.Name like \'foo%\';
When I try to execute this que
This will perform better:
SELECT COUNT(*) OVER (), c.*
FROM CUSTOMER c
WHERE c.Name like 'foo%';
One approach is to do something like the following. This will result in a count(*) result for each line. But beware, there is a Cartesianjoin; if you have many rows like 'foo%' this will perform badly.
select a.cntr, c.*
from CUSTOMER c
, (select count(*) cntr
from customer b
where b.name like 'foo%' ) a
where c.name like 'foo%'