HQL(Hibernate Query Language)を使用して、2つのテーブル間にユニオンを作成しようとしています。このSQLスクリプトは、私のSQLサーバーで正常に機能します。
SELECT COUNT(DISTINCT linkedin_id) as test, school_name
FROM
(SELECT * FROM alum_education
UNION
SELECT * FROM alum_connection_educations) AS UNIONS where school_name='some string'
問題は、私がこのようなグレイルでそれを実行しようとすると、次のようになります。
def countOfEdu = AlumEducation.executeQuery("select count (distinct linkedinId ) as countOfEdu, schoolName as SchoolName from (SELECT * FROM alumEducation UNION SELECT * FROM alumConnectionEducations) AS UNIONS where schoolName='some string'" )
このエラーが発生します:
org.hibernate.hql.ast.QuerySyntaxException: unexpected token: ( near line 1, column 83 [select count(distinct linkedinId ) as countOfEdu, schoolName as SchoolName from (SELECT * FROM alumEducation UNION SELECT * FROM alumConnectionEducations) AS UNIONS where schoolName='Duquesne University']
上記のSQLステートメントをgrailsで実行するにはどうすればよいですか?
ありがとうジェイソン