如何在SQL中优化/替换游标?

时间:2014-05-23 17:54:15

标签: sql sql-server sql-server-2008 tsql database-cursor

我正在使用光标,并想知道这是否可以废除和优化?

1 个答案:

答案 0 :(得分:0)

SELECT s.StudentId, COUNT(*) AS CreationCount 
FROM Student s
INNER JOIN CreationHist c
    ON c.StudentId = s.StudentId
WHERE c.CreateDate = '05/02/2011'
GROUP BY s.StudentId