Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
SQL for overlapping ranges
select prod_a as "Prod", prod as "Range of Amounts", value as "Mean Price" from ( with tablea(prod,amt,price) as ( select 'X',100,1 from dual union all select 'X',180,2 from dual union all select 'X',250,3 from dual union all select 'Y',90, 2 from dual union all select 'Y',170,3 from dual union all select 'Y',280,3 from dual ) select prod as prod_a, avg(case when amt between 0 and 200 then price end) as avg_0_200, avg(case when amt between 150 and 300 then price end) as avg_150_300 from tablea a group by prod ) b unpivot(value for prod in(avg_0_200,avg_150_300)) order by prod_a
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
DBMS
test database table
add pl/sql
Srinivas
Srinivas
Srinivas
Srinivas
Srinivas
even and odd plsql block
PL/SQL variables and constant
Please log in to post a comment.