2013-08-21 2 views
0

привет, я хочу преобразовать мой sql subselect запрос в hql. мой SQL запрос показан нижеКак преобразовать sql subselect запрос в hql?

select distinct sum(goal_score) from(
select user_id,max(goal_score) goal_score from sc_student_final_results ssfr 
where month=8 and year=2013 group by goal_id,user_id) ssfr group by ssfr.user_id 

для або родной команды SQL я преобразуется в HQL, как показано ниже

select distinct sum(goalScore) FROM (select userId,max(goalScore) goalScore FROM 
StudentFinalResults sr where year=:year and month=:month and locationId =:siteid 
group by userId,goalId) sr group by sr.userId 

, но я получаю ошибку

org.hibernate.hql.PARSER - line 1:37: unexpected token: (
org.hibernate.hql.PARSER - line 1:52: unexpected token: max 
unexpected token: (near line 1, column 37 [select distinct sum(goalScore) 
FROM (select userId,max(goalScore) goalScore FROM 
net.sankhya.scorecards.model.StudentFinalResults sr where year=:year and 
month=:month and locationId =:siteid group by userId,goalId) sr group by sr.userId] 

ответ

0

Пожалуйста, обновите ваш запрос с этим, это может сработать!

select distinct sum(sr3.goalScore) FROM (select userId,max(goalScore) FROM 
StudentFinalResults sr2 where year=:year and month=:month and locationId =:siteid 
group by userId,goalId) sr3 group by sr3.userId 
Смежные вопросы