Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

cross join returns 0 records

waqarazeemFeb 17 2010 — edited Feb 17 2010
Q1.

My cross-join return 0 records if any of the table, either table A or table B, is empty. Please confirm.

Q2.

I need to generate a salary slip.

my first query is:

select sh.headname Allownces, ee.amount Amount from hrm_employeeentitlement ee
inner join hrm_salaryhead sh on ee.hrm_salaryhead_id = sh.hrm_salaryhead_id
where ee.hrm_salaryheadtype_id = 1000000

my second query is:

select sh.headname Deductions, ee.amount Amount, ee.balance Balance from hrm_employeeentitlement ee
inner join hrm_salaryhead sh on ee.hrm_salaryhead_id = sh.hrm_salaryhead_id
where ee.hrm_salaryheadtype_id = 1000001

now i have taken a cross join of both

select vallownces.Allownces, vallownces.Amount, vdeductions.Deductions, vdeductions.Amount, vdeductions.Balance
from
(
select sh.headname Allownces, ee.amount Amount from hrm_employeeentitlement ee
inner join hrm_salaryhead sh on ee.hrm_salaryhead_id = sh.hrm_salaryhead_id
where ee.hrm_salaryheadtype_id = 1000000
) vallownces cross join
(
select sh.headname Deductions, ee.amount Amount, ee.balance Balance from hrm_employeeentitlement ee
inner join hrm_salaryhead sh on ee.hrm_salaryhead_id = sh.hrm_salaryhead_id
where ee.hrm_salaryheadtype_id = 1000001
)

returns 0 records because second sub-query is empty.


Q 3:

any alternate please ?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 17 2010
Added on Feb 17 2010
8 comments
1,646 views