Error in OQL

0
Hi All, I am running below query in Postgres.It worked fine,but when I tried the same query in Java I am getting error message -Join element contains invalid location Can any one kindly suggest does Mendix support below query or there is syntax eerror in below query? SELECT A.Attribute1,A.Attribute2 ,A.Attribute3, A.Attribute4 FROM "Module"."Entity" AS A INNER JOIN ( SELECT B.Attribute1 as a1,MAX(B.Attribute2) as a2 FROM "Module"."Entity" AS B WHERE B.Attribute1='0030' GROUP BY B.Attribute1,B.Attribute2 ) AS C ON A.Attribute1=C.a1AND A.Attribute2 =C.a2
asked
2 answers
2

Although it looks like: OQL is not SQL.

You will need something like

FROM "Module"."Entity" AS A
WHERE A.Attribute2 = (SELECT MAX(Attribute2) From A/Module.Entity_Entity/Module.Entity AS B 
                      Where B.Attribute1 = A.Attribute1 and B.Attribute2 = A.Attribute2 and B.Attribute1='0030' )
 SELECT A.Attribute1,A.Attribute2 ,A.Attribute3, A.Attribute4
answered
0

Even I tried the below as well .Its also being supported in Postgres but not in OQL(Java)

Is there any syntax to write subquery in Mendix?

SELECT A.Attribute1,A.Attribute2 ,A.Attribute3, A.Attribute4
FROM "Module"."Entity" AS A where (A.Attribute1,A.Attribute2) IN ( SELECT SELECT B.Attribute1 as a1,MAX(B.Attribute2) FROM "Module"."Entity" AS B GROUP BY B.Attribute1 )

answered