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!

SQL Query using Subquery to get the difference in budget versions

user11974873Nov 18 2009 — edited Nov 19 2009
Hi

I am using the following query to find the difference between revenue budget changes from the previous version to latest version. However the second subquery is not working. Has somebody done a similar query before? Any help?

select distinct b.name, b.segment1, a.version_number , a.version_name, a.change_reason_code, a.revenue, f.revenue, a.creation_date, d.full_name
from PA_BUDGET_VERSIONS a, pa_projects_all b, fnd_user c, per_all_people_f d,PA_BUDGET_VERSIONS f
where a.project_id = b.project_id
and a.created_by = c.user_id
and c.employee_id = d.person_id
and a.budget_type_code = 'AR'
and a.budget_status_code = 'B'
and b.org_id in (147,707,140)
and a.version_number in (select max(e.version_number) from PA_BUDGET_VERSIONS e where e.budget_version_id = a.budget_version_id
and a.project_id = e.project_id)
and a.budget_version_id = f.budget_version_id
and f.version_number in (Select max(g.version_number) from PA_BUDGET_VERSIONS g where f.budget_version_id = g.budget_version_id
and f.project_id = g.project_id and g.version_number < a.version_number)
and a.creation_date between '01-JAN-09' and '30-JAN-09'
order by b.segment1;
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 17 2009
Added on Nov 18 2009
4 comments
1,157 views