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
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
)