By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create table main (jan decimal(16,2), feb decimal(16,2), mar decimal(16,2))
create table new_comp (newp decimal(16,2), startv decimal(16,2), endv decimal(16,2))
insert into main(jan, feb, mar) values
(16.25, 19.56, 25.09),
(52.01, 62.22, 71.05),
(84.72, 92.76, 100.00)
insert into new_comp (newp, startv, endv) values
(0.60, 0.00, 0.20),
(0.75, 0.20, 0.40),
(0.81, 0.30, 0.50),
(0.89, 0.50, 0.70),
(0.93, 0.70, 1.00)
select * from main
select * from new_comp
jan | feb | mar |
---|---|---|
16.25 | 19.56 | 25.09 |
52.01 | 62.22 | 71.05 |
84.72 | 92.76 | 100.00 |
newp | startv | endv |
---|---|---|
0.60 | 0.00 | 0.20 |
0.75 | 0.20 | 0.40 |
0.81 | 0.30 | 0.50 |
0.89 | 0.50 | 0.70 |
0.93 | 0.70 | 1.00 |
create view vwMainAndValue as
select m.jan,
m.feb,
m.mar,
c.newp,
c.startv,
c.endv
from main m
left join new_comp c on m.jan between c.startv * 100 and c.endv * 100
select * from vwMainAndValue
jan | feb | mar | newp | startv | endv |
---|---|---|---|---|---|
16.25 | 19.56 | 25.09 | 0.60 | 0.00 | 0.20 |
52.01 | 62.22 | 71.05 | 0.89 | 0.50 | 0.70 |
84.72 | 92.76 | 100.00 | 0.93 | 0.70 | 1.00 |
drop view vwMainAndValue
drop table main
drop table new_comp