我对问题的输出是: -
FIRSTNAME COURSENAME
---------- --------------------
Anand C++
Bala C++
Dileep Linux and C
Gowri Java
Gowri Linux and C
Gowri C#
John C++
John Oracle
Prem Linux and C
Priya Java
Priya Oracle
Priya C#
Rahul Oracle
但预期的输出是: -
FIRSTNAME COURSENAME
---------- --------------------
Anand C++
Bala C++
Dileep Linux and C
Gowri C#
Gowri Java
Gowri Linux and C
John C++
John Oracle
Prem Linux and C
Priya C#
Priya Java
Priya Oracle
Rahul Oracle
我的代码:
select firstname, coursename
from course
inner join
(select student.firstname as firstname, registration.courseid
from student
inner join registration on student.studid = registration.studid
group by student.firstname, registration.courseid) q1 on q1.courseid = course.courseid
order by firstname asc;
如何按升序排列两列保持另一列固定? (也许我在解释这个问题时听起来不太好)
答案 0 :(得分:3)
order by firstname, coursename
或者
order by firstname asc, coursename asc