I want to find a wholesum resultset, limited to 25 records, in the following way:
- Users from Table1 based on a condition
- And those Users should not be in Table2 [Non restricted users]
- Join those records to Table3 on Table1.Group_id = Table3.Group_MEMBER_ID where Table3.GroupName = 'someValue'
- Join Table1 with Table4 on Table1.UserName = Table4.UserName
Am currently using two queries and am using UNION. Something like this:
( SELECT Table_4.DeviceName
left join Table2 on Table1.UserName = Table2.UserName
inner join Table4 on Table1.UserName = Table4.UserName
where Table1.some_column = 'someValue'
and Table2.UserName = null
( SELECT Table4.DeviceName
inner join on Table1.Group_ID = Table3.GROUP_MEMBER_ID
inner join Table4 Table1.UserName = Table4.UserName
and Table1.some_column = 'someValue'
The point is, I cant limit the wholesum resultset to 25 records. I should use LIMIT to each query. Is there a way to merge it into a single query so that I can limit the wholesum resultset to 25?
Note: PL/SQL and CTE not available in my Development System and hence am not able to use it.