解決了
select * from (select col,count(col) as c from table group by col) as t order by t.c
本來的目標是 MAX(...) ,結果 這么一句 HQL 語句總是得不到結構:
string query = "SELECT MAX(ID) FROM Student";
另外兩句:"SELECT MAX(Student.ID) FROM Student " 和 "SELECT MAX(ID) FROM Student AS stud";
同樣得不到結果,返回的的均是 Student 對象集合
剛開始以為不支持 MAX 函數,但是SELECT COUNT() FROM Student ,就可以正確返回紀律數,而且很多文檔也多證明了HQL支持ANSI SQL集合函數,
終于發現 只有 "SELECT MAX(stud.ID) FROM Student AS stud";
當然 "SELECT MAX(stud.ID) FROM Student stud" 也是正確的
轉載請標明出處:http://blog.csdn.net/Jinglecat/archive/2005/08/03/445296.aspx