**Editted my answer **
No need for OPEX_Total. Try this:
FROM PM_Tool.OPEX P
GROUP BY P.Category as Category
SELECT Category, SUM(P.Value) as Total
Does this work?
Also, for creating and trying out OQL’s, and for lots of examples, see the demo-page https://service.mendixcloud.com/p/OQL
Call it from a microflow, just feed it an OQL-boject, containing a valid OQL in the attribute ‘OQL’:
Hi Dmitri,
There are two ways for you to solve this:
I would highly recommend #1
Regards,
Shekhar
Dear Shekhar,
I'm trying to use OQL (via "Execute OQL statement" element) if you suggested below. What I need to extract the sum of all "Value" as list (for ListView on the page) from OPEX table filtered by Year and Category.
I’m struggling with getting “Category” (Enumeration) and “Year” (Date and Time) from the persistent Entity “OPEX” to non-persistent Entity “OPEX_Total”. The system gives me an error. “Comment” and “Value” fields are fed without any issue.
The following simple code works:
'
SELECT
P.id OPEX_Total_OPEX,
P.Value OTotal,
P.Comment OComment
FROM
PM_Tool.OPEX P
'
But when I apply more complex functionality the system crushes. The following code doesn’t work. The syntax might be wrong, but I tried to feed only “Year” or only “Category” with no success:
'
SELECT
P.id OPEX_Total_OPEX,
P.Value OTotal,
P.Year OYear
FROM
PM_Tool.OPEX P
Where P.Category = P.Category.Vendor_External_Maintenance
'
Dear Dmitrii,
There is an issue with your OQL query, kindly use the query as below:
SELECT category,
SUM(Value) Cat_Total
FROM PM_Tool.OPEX
GROUP By category
SELECT year,
SUM(Value) Year_Total
FROM PM_Tool.OPEX
GROUP By year
SELECT category,
year,
SUM(Value) CatYear_Total
FROM PM_Tool.OPEX
GROUP By category, year
Execute these statements from ExcuteOQLStatement action from a microflow. I am showing screenshots below of one of my OQL statements