如何编写查询以获取一列中不同的记录和另一列中的desc顺序。
我可以使用以下语句获取记录。
select * from
(select * from t1
where id=14
order by ttimestamp desc) as h
group by hnumber
order by ttimestamp desc
但是当我在JPA中尝试相同的时候。
SELECT m from
(SELECT m from t1 m
WHERE m.user = :user
ORDER BY m.tTimestamp DESC) as h
GROUP BY m.hNumber
ORDER BY m.tTimestamp DESC
我收到错误提示语法错误。
Exception Description: Syntax error parsing [SELECT m from (SELECT m from t1 m WHERE m.user = :user ORDER BY m.tTimestamp DESC) as h GROUP BY m.hNumber ORDER BY m.tTimestamp DESC].
The right parenthesis is missing from the sub-expression.
An identification variable must be provided for a range variable declaration.
The query contains a malformed ending.
感谢任何帮助。