SQL Language (MOSC)

MOSC Banner

Use SUM PARTITION BY in DB view

in SQL Language (MOSC) 11 commentsAnswered ✓

Dear Sir / Madam,

I want to create a DB view with SUM PARTITION BY column definition. However, when I join the DB view with a where-clause, the value of SUM PARTITION BY is not subject to change by the where-clause. For example:

create view test_view as

select employee_number, leave_start_date, sum(leave_duration) (partition by employee_number) as sum_of_duration from apps.leave_table;

then I create a SQL like this:

select * from test_view where leave_start_date >= sysdate - 7;

I expect the sum_of_duration would be changed if I provide different value for the where-clause (leave_start_date >= ?). However it doesn't. Do you have any idea and any alternative for this?

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center