MySQL alias is listed in Chinese, without the quotation marks when the Order by clause to use an alias

The reason is not clear yet

 

 

 

1, average grades from high to low scores show all courses and all students grade point average

SC table:

 

 

Here, as a total score of treatment

SELECT SID, SUM (Score) AS  ' total score ' , AVG (Score) AS  ' mean score ' 
from SC
 Group  by SID
 Order  by   GPA   desc ;

The result: This is the order by clause "grade point average" is not quoted, correctly in descending order

 

 

 

 

SELECT SID, SUM (Score) AS  ' total score ' , AVG (Score) AS  ' mean score ' 
from SC
 Group  by SID
 Order  by   ' mean score '   desc ;

The result: the average score in quotes, order by clause can not be sorted correctly

 

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/bravesunforever/p/11808744.html