showing the number sequence of displayed data [message #480126] |
Thu, 21 October 2010 05:43 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
Amar_bu
Messages: 32 Registered: July 2010 Location: riyadh
|
Member |
|
|
Hi
I have query in that query i should display the number of row.I have tried to select the rownum but when i use it the data will be duplicated.
I have found something that related to use temprory table, or subquery but all of them will not work becuase the query depends on many tables and if i use temprory table filling the table and then reading from it will take too long time.
Any idea??
[Updated on: Thu, 21 October 2010 05:44] Report message to a moderator
|
|
|
|
Re: showing the number sequence of displayed data [message #480249 is a reply to message #480134] |
Fri, 22 October 2010 02:02 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
Amar_bu
Messages: 32 Registered: July 2010 Location: riyadh
|
Member |
|
|
This is the query
SELECT nvl(sum(I.revenue),i.period, rownum
from pa_budget_versions bv,
pa_proj_fp_options po,
XX_PA_BUDGET_TYPES_V b,
PA_BUDGET_LINES I,
pa_projects_all pa_all,
WHERE bv.wp_version_flag = 'N'
AND bv.version_type = 'REVENUE'
AND bv.budget_status_code = 'B'
and bv.approved_rev_plan_type_flag= 'Y'
and bv.CURRENT_FLAG = 'Y'
and bv.FIN_PLAN_TYPE_ID = b.FIN_PLAN_TYPE_ID
and b.NAME = 'Approved Budget'
AND pa_all.org_id = fnd_profile.VALUE('ORG_ID')
and bv.budget_version_id=i.budget_version_id
AND bv.budget_version_id = po.fin_plan_version_id
AND bv.fin_plan_type_id = po.fin_plan_type_id
AND bv.project_id = po.project_id
AND po.fin_plan_option_level_code = 'PLAN_VERSION'
AND bv.project_id = pa_all.project_id ;
group by i.period, to_char(i.period,'MM'),rownum
order by to_char(i.period,'MM')
[Updated on: Fri, 22 October 2010 02:04] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
Re: showing the number sequence of displayed data [message #482682 is a reply to message #482482] |
Mon, 15 November 2010 05:27 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
Amar_bu
Messages: 32 Registered: July 2010 Location: riyadh
|
Member |
|
|
HI
sorry for being late in replay. I have used analytical function row number
SELECT nvl(sum(I.revenue),
row_number() over (order by to_number(to_char(i.start_date,'MM')) ) as pay_no
from pa_budget_versions bv,
pa_proj_fp_options po,
XX_PA_BUDGET_TYPES_V b,
PA_BUDGET_LINES I,
pa_projects_all pa_all,
WHERE bv.wp_version_flag = 'N'
AND bv.version_type = 'REVENUE'
AND bv.budget_status_code = 'B'
and bv.approved_rev_plan_type_flag= 'Y'
and bv.CURRENT_FLAG = 'Y'
and bv.FIN_PLAN_TYPE_ID = b.FIN_PLAN_TYPE_ID
and b.NAME = 'Approved Budget'
AND pa_all.org_id = fnd_profile.VALUE('ORG_ID')
and bv.budget_version_id=i.budget_version_id
AND bv.budget_version_id = po.fin_plan_version_id
AND bv.fin_plan_type_id = po.fin_plan_type_id
AND bv.project_id = po.project_id
AND po.fin_plan_option_level_code = 'PLAN_VERSION'
AND bv.project_id = pa_all.project_id ;
group by i.start_date
order by to_char(i.start_date,'MM')
also, i could use count but analytical function is faster than count summary column
|
|
|