Hi,
I'm unable to create join from select in HQL (Question are on botton). I have such situation:
Code:
Class Record {
Date day;
int value_index;
long value;
}
And folowing data (number represets unique record of column type):
day,value_index,value
Code:
1, 0, 20
1, 1, 22
1, 2, 23
2, 1, 10
2, 2, 11
3, 1, 11
For each day i have 1..n records, they are indexed with value_index (incremental). I want fetch from DB for each day this records that have max(value_index) for this day:
Requesting result:
Code:
1,2,23
2,2,11
3,1,11
In SQL i will do this with join from subselect:
Code:
select * from Record r1
join (select day, max(value_index) from Record group by day) r2
on r1.day = r2.day
In HQL - this concept does't work:
Code:
select r1 from Record r1
join (select r.day, max(r.value_index) from Record r group by r.day) r2
on r1.day = r2.day
--- QUESTION----Is in HQL some way to receive such result?
Are joins from subselect in HQL unsuported?
Where can i found exact syntax of HQL (Something like for SQL:
Code:
SELECT <column list>
FROM <left joined table>
[INNER] JOIN <right joined table>
ON <join condition>
)?