I wonder how I convert this SQL statement to JPQL:
SELECT sum(price) AS Income, count(*) AS Passages, Station.Name
FROM Passage
INNER JOIN station ON passage.stationId = station.id
GROUP BY Station.Name
wouldnt it be something like this:
SELECT sum(price) AS Income, count(p) AS Passages, s.Name FROM Passage p
INNER JOIN station s
ON p.stationId = s.id GROUP BY s.Name
?
Problem solved with:
SELECT count(p), sum(p.price), s
FROM Passage p
INNER JOIN p.station s
GROUP BY s.name;