Question : T-SQL Query

Is there a way to rewrite this query so that it would run faster?
1:
2:
3:
4:
5:
6:
7:
SELECT
	a.*,
	(SELECT COUNT(*) FROM MyTable asub WHERE Field1 = 'MyValue' AND asub.ID = a.ID)
FROM
	MyTable a
WHERE
	a.Feild1 = 'MyValue'

Answer : T-SQL Query

This should do:

SELECT *, COUNT(*) over (Partition by ID) count_value
FROM MyTable
WHERE a.Feild1 = 'MyValue'
Random Solutions  
 
programming4us programming4us