TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Muhammad younas
NA
169
482.7k
selct max row from a table
Oct 2 2012 5:31 AM
i have a table which include fields, subjectname,title,status,marks
a subjectname can have more than one row with different marks , i have to select row with maximum marks.
for example
i have 5 rows with record.
subjectname | title| marks|status
maths | basic| 66|paid
maths | basic| 89|not paid
maths | basic | 73|paid
computer | basic | 39|paid
computer | basic | 78|paid
the result i need is
maths | basic| 89
computer|basic |78
i used
SELECT subjectName, MAX(Marks) AS Expr1
FROM OnlineTestResults
that is
maths | 89
computer|78
it ives required result but when i use
SELECT Status, TestName, MAX(Marks) AS Expr1
FROM OnlineTestResults
it give wrong result as
maths | 89|Not Paid
maths|73|paid
computer|78
can any one help me??????
Reply
Answers (
4
)
t-sql 2008 not returning all data
Passwords are stored in sql server