First of all,
GROUP BY
should appear before
ORDER BY
clause.
ORDER BY
should be the last clause in your SELECT query.
You haven't used any aggregate function for which
GROUP BY
is required.
If you want to unique records in a result set use
DISTINCT
clause with
ORDER BY
if required.
Just remove/ comment out the
GROUP BY
and it should work fine. You can add a
DISTINCT
tag if you need.
SELECT DISTINCT students_details.class AS Class, students.name AS Name, students.guardian AS Gurdian, students.phone AS Phone, students.mobile AS Mobile
FROM students_det INNER JOIN students ON students_details.studentID = students.studentID
ORDER BY students_details.class
Hope, it helps :)