Search code examples
sqljpajpql

SQL subselect to jpql


How can i write this sql in jpql syntax?

SELECT
SUM(t1.preise)
FROM
 (
SELECT
  preise
FROM
  `preistabelle`
ORDER BY
  `pid` DESC
LIMIT
  6  
 ) as t1

It is a subselect. I get an error if i try something like this:

SELECT sum(t1.preise) FROM (SELECT a.totalGRP FROM preise a) as t1

Error is unexpected token "("


Solution

  • You can't. It's not supported by JPQL.