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?
-
- In need of some credit
- Posts: 1
- Joined: Sat Jun 25, 2016 7:45 am
-
- Moderator
- Posts: 19164
- Joined: Fri Apr 21, 2006 8:03 pm
- Location: $FCE2
Re: What’s wrong in the following query?
What's the table structure for "students"?
Use the source, Luke!
-
- Super wx Problem Solver
- Posts: 282
- Joined: Tue Mar 19, 2013 8:52 pm
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.
-
- 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.