case when SQL to JPAContainer

Could I query ‘case when’ sql statement to JPAContainer?

sql statement as below:

select issue, sum(case when STATUS='NORMAL' THEN 1 ELSE 0 END) as NORMAL, sum(case when STATUS='WARNING' THEN 1 ELSE 0 END) as WARNING, sum(case when STATUS='CRITICAL' THEN 1 ELSE 0 END) as CRITICAL from history_table group by issue I guess I need to follow “19.7. Querying with the Criteria API”. But I have no idea how to implement ‘case when’. Could someone give me the example?

And I dont understand what is the different between these two methods. I think usuablly I should ‘orderByWillBeAdded()’?
orderByWillBeAdded()
orderByWasAdded()

Thanks.

Did you try looking at
SqlContainer
? This solves the problem what you are looking at…

Or can you please tell us the context on why you are using JPAContainer over SqlContainer, So that we can help you

I am using JPAContainer for my project. I create two view without the problem. Now I want to create one more view, the data source is from the sql as my post. I think “19.7. Querying with the Criteria API” maybe could help, I will try. I am look for someone could give me hints. Thanks.

I believe the view to be a Table, why don’t you go with Generated Columns? instead of using case statements get the actual value as is from the DB and use Table generated columns to render the data according to your need using if statements.

Hope this solves the problem

Thanks for reply. I try many query from this link but failed.
https://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Querying/Criteria

I guess JPAContainer does not support to modify select part of query. I can not find any example from this forum and google. Maybe I should giveup JPAContainer.