1
SELECT hits.api_name,
       hits.hitcount,
       r.unit_rate*hits.hitcount AS amnt
FROM
  (SELECT u.api_name AS api_name,
          u.tenant_id,
          u.count AS hitcount
   FROM tableA u
   WHERE u.tenant_id = :tenant
     AND u.time_stamp BETWEEN :dateFrom AND :dateTo
   GROUP BY u.api_name,
            u.tenant_id) AS hits
LEFT JOIN tableB r ON hits.api_name = r.api_name
AND hits.tenant_id =r.tenant_id

This is nativesql query and i am passing the parameters by using @Param and it is working fine. Now i need to write in jpql query using spring data jpa. I am unable to write inner queries in jpql using spring data jpa. can you please tell me the solution.

Justin
  • 9,634
  • 6
  • 35
  • 47
madhuri
  • 63
  • 8

0 Answers0