Tuesday, September 7, 2010

T-SQL: HOW TO USE T-SQL TOP KEYWORD‏

In this post I am gonna tell you how to use T-SQL top  keyword. Basically top keyword is use to show top records from the result set. Top keyword takes no of rows as an argument and shows them from the result set.

SELECT TOP(5)
SI.Name,
SUM(MarksObtained) 'Marks Obtained'
FROM StudentCourse SC
JOIN StudentInfo SI ON SI.StudentId = SC.StudentId

GROUP BY SC.StudentiD, SI.Name
ORDER BY SI.Name DESC

This is how you can utilize top keyword. Have a nice day.

No comments:

Post a Comment