我輸出的問題是這樣的: -如何訂購SQL中的兩列?
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;
如何安排在上升兩列訂單保持另一個固定? (也許我沒聲音在解釋這個好)
你想通過列名字訂購然後coursename? –
可能重複的[SQL多列排序](https://stackoverflow.com/questions/2051162/sql-multiple-column-ordering) –