SELECT student_code, name
FROM students
WHERE marks =
(SELECT MAX(marks)
FROM students
GROUP BY subject_code);
pls suggest me for this
i am stuck here
What’s wrong in the following query?
Re: What’s wrong in the following query?
What's the table structure for "students"?
Use the source, Luke!
Re: What’s wrong in the following query?
... and what is the problem you are having, and which database are you using (may or may not be relevant)?
For a start, the GROUP BY clause is probably redundant because MAX(marks) should only return a single result in the sub-query, did you mean:
Code: Select all
SELECT student_code, name
FROM students
WHERE marks =
(SELECT MAX(marks)
FROM students
GROUP BY subject_code);
Code: Select all
SELECT student_code, name
FROM students
WHERE marks =
(SELECT MAX(marks)
FROM students)
GROUP BY subject_code;
wxWidgets 3.1.2, MinGW64 8.1.0, g++ 8.1.0, Ubuntu 19.04, Windows 10, CodeLite + wxCrafter
Some people, when confronted with a GUI problem, think "I know, I'll use Eclipse RCP". Now they have two problems.
Some people, when confronted with a GUI problem, think "I know, I'll use Eclipse RCP". Now they have two problems.
- marcelinux
- Knows some wx things
- Posts: 40
- Joined: Thu Nov 07, 2013 9:59 pm
- Location: Madrid, Spain
Re: What’s wrong in the following query?
An agregate function need explicit all others columns in the table:malisha21 wrote:SELECT student_code, name
FROM students
WHERE marks =
(SELECT MAX(marks)
FROM students
GROUP BY subject_code);
... GROUP BY subject_code, student_code, name;
isn't it?
I just need learn a little bit more. Thank you for your help.