Run Code
|
Code Wall
|
Users
|
Misc
|
Feedback
|
About
|
Login
|
Theme
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 Lab Work
temporal overlap in oracle
max of 2(function)
fiddle for between
Factorial from SQL
Trig
Count of 'A' from given string
PL/SQL Control Statements
Sum of n numbers
Please log in to post a comment.