I have a requirement when I need to limit the number of records returned from a table for a certain flag and all records for a different flag value.
For example: the contact-history table has an element named IorM_flg with possible values โโof "m" and "o".
I need to return only 10 entries of 'o' and all entries of 'm'.
I was going to write a join query for this. Something like that:
select ch from contact_history where ch.rownum <= 10 and ch.IorM_flg = 'o' Union All select ch from contact_history where ch.IorM_flg != 'o'
Is it possible? Please note that this is a JPA request. (contact_history - object name)
Any other best offers are welcome!
source share