convert rows to columns in oracle [duplicate] - oracle

I have folowing Dataout put from my query
**Date** **HIGH** **LOW** **IMAGE** **TYPE**
1/28/2012 69 42 1.jpg SUN
1/29/2012 70 42 2.jpg MSUN
I want to Convert this Output into
**1/28/2012** **1/29/2012**
1.jpg 2.jpg
Sun MSUN
69 72
42 42
Here is My query
SELECT
W_DATE,HIGH, LOW,
W_TYPE, IMAGE
FROM WEATHER
ORDER BY W_DATE ASC
And Also I have multiple dates in rows i want to display only 4 dates and they should change when system date is chanaged

About all the possibilities how get from rows to columns in oracle you can read up here:
http://www.dba-oracle.com/t_converting_rows_columns.htm
I don't see a straight forward solution for that from database point of view - would suggest to do the formatting on application side, otherwise it could look as lame as this:
SELECT
to_char(w1.w_Date,'MM/DD/YYYY'), to_char(w2.w_Date,'MM/DD/YYYY'),
to_char(w3.w_Date,'MM/DD/YYYY'), to_char(w4.w_Date,'MM/DD/YYYY')
FROM
(select * from weather where w_date = trunc(sysdate)) w1,
(select * from weather where w_date = trunc(sysdate) + 1) w2,
(select * from weather where w_date = trunc(sysdate) + 2) w3,
(select * from weather where w_date = trunc(sysdate) + 3) w4
UNION ALL
SELECT
w1.image, w2.image, w3.image , w4.image
FROM
(select * from weather where w_date = trunc(sysdate)) w1,
(select * from weather where w_date = trunc(sysdate) + 1) w2,
(select * from weather where w_date = trunc(sysdate) + 2) w3,
(select * from weather where w_date = trunc(sysdate) + 3) w4
UNION ALL
SELECT
w1.w_type, w2.w_type, w3.w_type , w4.w_type
FROM
(select * from weather where w_date = trunc(sysdate)) w1,
(select * from weather where w_date = trunc(sysdate) + 1) w2,
(select * from weather where w_date = trunc(sysdate) + 2) w3,
(select * from weather where w_date = trunc(sysdate) + 3) w4
UNION ALL
SELECT
to_char(w1.high), to_char(w2.high), to_char(w3.high) , to_char(w4.high)
FROM
(select * from weather where w_date = trunc(sysdate)) w1,
(select * from weather where w_date = trunc(sysdate) + 1) w2,
(select * from weather where w_date = trunc(sysdate) + 2) w3,
(select * from weather where w_date = trunc(sysdate) + 3) w4
UNION ALL
SELECT
to_char(w1.low), to_char(w2.low), to_char(w3.low) , to_char(w4.low)
FROM
(select * from weather where w_date = trunc(sysdate)) w1,
(select * from weather where w_date = trunc(sysdate) + 1) w2,
(select * from weather where w_date = trunc(sysdate) + 2) w3,
(select * from weather where w_date = trunc(sysdate) + 3) w4;
/

Related

How can I extract columns name from row value of another table(oracle sql)?

I have 2 tables:
table1
no
a
b
c
x1
2
3
4
x2
10
11
12
x3
20
21
22
table2
from_val
in_out
cf_pv
term
a
out
cf
b
b
out
pv
b
c
in
cf
e
Define sum_out is sum of a, b, c in table1 with condition in_out='out' in table2 and sum_cf is sum of a, b, c in table1 with condition cf_pv='cf' in table2.
Shortly, values of from_val in table2 are columns name i.e. a, b, c in table1.
How can I extract and calculate sum_out or sum_cf of every no in Oracle?
sum_out of x1 = 2 + 3
sum_out of x2 = 10 + 11
sum_out of x3 = 20 + 21
sum_cf of x1 = 2 + 4
sum_cf of x2 = 10 + 12
sum_cf of x3 = 20 + 22
Thanks!
'''''''''''''''''''''''''''''''''''''''''''''
in additional,
i want to calculate
sum_out and cf of x1= 2 (=a)
sum_out and cf of x2= 10 (=b)
sum_out and cf of x3= 20 (=c)
Sample data
WITH
tbl_1 AS
(
Select 'x1' "COL_NO", 2 "A", 3 "B", 4 "C" From Dual Union All
Select 'x2' "COL_NO", 10 "A", 11 "B", 12 "C" From Dual Union All
Select 'x3' "COL_NO", 20 "A", 21 "B", 22 "C" From Dual
),
tbl_2 AS
(
Select 'A' "FROM_VAL", 'out' "IN_OUT", 'cf' "CF_PV", 'begin' "TERM" From Dual Union All
Select 'B' "FROM_VAL", 'out' "IN_OUT", 'pv' "CF_PV", 'begin' "TERM" From Dual Union All
Select 'C' "FROM_VAL", 'in' "IN_OUT", 'cf' "CF_PV", 'end' "TERM" From Dual
),
Create CTE (formulas) that generates formulas for IN_OUT = 'out' and For CF_PV = 'cf'
formulas AS
(
Select
CASE WHEN IN_OUT = 'out' THEN IN_OUT END "IN_OUT",
LISTAGG(FROM_VAL, ' + ') WITHIN GROUP (ORDER BY FROM_VAL) OVER(PARTITION BY IN_OUT) "IN_OUT_FORMULA",
CASE WHEN CF_PV = 'cf' THEN CF_PV END "CF_PV",
LISTAGG(FROM_VAL, ' + ') WITHIN GROUP (ORDER BY FROM_VAL) OVER(PARTITION BY CF_PV) "CF_PV_FORMULA"
From
tbl_2
),
IN_OUT
IN_OUT_FORMULA
CF_PV
CF_PV_FORMULA
C
cf
A + C
out
A + B
cf
A + C
out
A + B
B
Another CTE (grid) to connect COL_NO to formulas
grid AS
(
Select
t1.COL_NO,
CASE WHEN f1.IN_OUT = 'out' THEN f1.IN_OUT END "IN_OUT", CASE WHEN f1.IN_OUT = 'out' THEN f1.IN_OUT_FORMULA END "IN_OUT_FORMULA",
CASE WHEN f1.CF_PV = 'cf' THEN f1.CF_PV END "CF_PV", CASE WHEN f1.CF_PV = 'cf' THEN f1.CF_PV_FORMULA END "CF_PV_FORMULA"
From
tbl_1 t1
Left Join
formulas f1 ON(f1.IN_OUT Is Not Null AND f1.CF_PV Is Not Null)
)
COL_NO
IN_OUT
IN_OUT_FORMULA
CF_PV
CF_PV_FORMULA
x1
out
A + B
cf
A + C
x2
out
A + B
cf
A + C
x3
out
A + B
cf
A + C
Main SQL to get the final result
SELECT
g.COL_NO,
g.IN_OUT,
g.IN_OUT_FORMULA,
CASE WHEN g.IN_OUT = 'out' And INSTR(IN_OUT_FORMULA, 'A') > 0 THEN A ELSE 0 END +
CASE WHEN g.IN_OUT = 'out' And INSTR(IN_OUT_FORMULA, 'B') > 0 THEN B ELSE 0 END +
CASE WHEN g.IN_OUT = 'out' And INSTR(IN_OUT_FORMULA, 'C') > 0 THEN C ELSE 0 END "CALC_OUT",
--
g.CF_PV,
g.CF_PV_FORMULA,
CASE WHEN g.CF_PV = 'cf' And INSTR(CF_PV_FORMULA, 'A') > 0 THEN A ELSE 0 END +
CASE WHEN g.CF_PV = 'cf' And INSTR(CF_PV_FORMULA, 'B') > 0 THEN B ELSE 0 END +
CASE WHEN g.CF_PV = 'cf' And INSTR(CF_PV_FORMULA, 'C') > 0 THEN C ELSE 0 END "CALC_CF"
FROM
grid g
INNER JOIN
tbl_1 t1 ON(g.COL_NO = t1.COL_NO)
R e s u l t :
COL_NO
IN_OUT
IN_OUT_FORMULA
CALC_OUT
CF_PV
CF_PV_FORMULA
CALC_CF
x1
out
A + B
5
cf
A + C
6
x2
out
A + B
21
cf
A + C
22
x3
out
A + B
41
cf
A + C
42

How to get the data from oracle on the following demand?

The table like this.
bh sl productdate
a1 100 2022-1-1
a1 220 2022-1-2
a1 220 2022-1-3
a2 200 2022-1-1
a2 350 2022-1-2
a2 350 2022-1-3
The result like this.
bh sl_q(sl_before) sl_h(sl_after) sl_b(changeValue) productdate
a1 100 220 120 2022-1-2
a2 200 350 150 2022-1-2
Rules:the same field bh, when the field sl change,then get the record.
We can use a ROW_NUMBER trick here:
WITH cte AS (
SELECT t.*, ROW_NUMBER() OVER (PARTITION BY bh ORDER BY productdate) rn1,
ROW_NUMBER() OVER (PARTITION BY bh ORDER BY productdate DESC) rn2
FROM yourTable t
)
SELECT bh, MAX(CASE WHEN rn1 = 1 THEN sl END) AS sl_q,
MAX(CASE WHEN rn2 = 1 THEN sl END) AS sl_h,
MAX(CASE WHEN rn2 = 1 THEN sl END) -
MAX(CASE WHEN rn1 = 1 THEN sl END) AS sl_b
FROM cte
GROUP BY bh;

(Oracle)Getting 25th number using interpolating

My goal is to get 25th number. For instance I have 4 row, such as 3,4,5 and 7.
My goal is to get 1.25th(=(4+1)0.25).
Expected result is 3.25 which is obtained by interpolating(3+0.25(4-3)).
I have tried as below.
But is there any other efficient way?
WITH DATASET AS (
SELECT 3 C1 FROM DUAL
UNION
SELECT 4 FROM DUAL
UNION
SELECT 5 FROM DUAL
UNION
SELECT 7 FROM DUAL
)
SELECT
--RNK, C1, NEXTC1-C1, FIRSTQLOCAION, FIRSTQLOCAION-RNK, C1+(NEXTC1-C1)*(FIRSTQLOCAION-RNK)
C1+(NEXTC1-C1)*(FIRSTQLOCAION-RNK)
FROM(
SELECT C1,
LEAD(C1, 1) OVER (ORDER BY C1) as NEXTC1 ,
RANK() OVER (ORDER BY C1) AS RNK,
((SUM(1) OVER (PARTITION BY NULL)) +1) * 0.25 AS FIRSTQLOCAION
FROM DATASET
)
WHERE
FIRSTQLOCAION>=RNK AND FIRSTQLOCAION<=RNK+1;
You can use analytical function as follows:
Select c1,
c1 + (
(((Count(1) over () + 1)*0.25) - 1) * (lead(c1) over (order by c1) - c1)
) as calculated_number from
From your_table t
In this solution last record will have calculated value null as lead value will be null and you will have to adjust its value as per your requirement.
If your expectation is a single number from query then usw following:
Select min(c1) +
0.25 * (min(case when rn = 2 then c1 end)
- min(case when rn = 1 then c1 end)) as calculated_number
from
(Select t.*,
Row_number() over (order by c1)
From t)
WITH t AS (
SELECT 3 C1 FROM DUAL
UNION
SELECT 4 FROM DUAL
UNION
SELECT 5 FROM DUAL
UNION
SELECT 7 FROM DUAL
)
SELECT rn,location, calculated
FROM (
Select rn, c1,
C1 +(Count(1) over () + 1)*0.25
-trunc( (Count(1) over () + 1)*0.25 ) *(lead(c1) over (order by c1) - c1) as calculated, --
trunc( (Count(1) over () + 1)*0.25 ) as location --
From (Select t.*, Row_number() over (order by c1) rn From t) ) WHERE rn=location;

Divide columns - oracle

Hello/ I need divide this table
I try use this but have bad result
SELECT MIN(y1),
MAX(y1),
MIN(redempamount1),
MAX(redempamount1),
MIN(f1),
MIN(f2),
MAX(f1),
MAX(f2)
FROM (SELECT to_number(y1) y1,
redempamount1,
add_months('02.03.2018', 12 * y1 - 12) f1,
add_months('02.03.2018', 12 * y1) - 1 f2,
row_number() over(PARTITION BY ntl ORDER BY rownum DESC) grp
FROM (SELECT to_number(t.y1) y1,
redempamount1,
add_months('02.03.2018', 12 * y1 - 12) f1,
add_months('02.03.2018', 12 * y1) - 1 f2,
ntile(2) over(ORDER BY rownum DESC) ntl
FROM inspolreport t))
GROUP BY grp;
Y1 REDEMPAMOUNT1 F1 F2
-- ------------- ---------- ----------
1 0 18.12.2008 17.12.2009
2 3362.54 18.12.2009 17.12.2010
3 6030.84 18.12.2010 17.12.2011
4 8873.52 18.12.2011 17.12.2012
5 11830.9 18.12.2012 17.12.2013
6 15041.83 18.12.2013 17.12.2014
7 18382.37 18.12.2014 17.12.2015
8 21857.15 18.12.2015 17.12.2016
9 25472.97 18.12.2016 17.12.2017
10 27359.51 18.12.2017 17.12.2018
11 31690.65 18.12.2018 17.12.2019
12 36195 18.12.2019 17.12.2020
13 40879.06 18.12.2020 17.12.2021
14 45750.5 18.12.2021 17.12.2022
15 53491.44 18.12.2022 17.12.2023
expected output
Y1 REDEMPAMOUNT1 F1 F2 Y2 REDEMPAMOUNT1 F3 F4
-- ------------- ---------- ---------- -- ------------- ---------- ----------
1 0 18.12.2008 17.12.2009 9 25472.97 18.12.2016 17.12.2017
2 3362.54 18.12.2009 17.12.2010 10 27359.51 18.12.2017 17.12.2018
3 6030.84 18.12.2010 17.12.2011 11 31690.65 18.12.2018 17.12.2019
4 8873.52 18.12.2011 17.12.2012 12 36195 18.12.2019 17.12.2020
5 11830.9 18.12.2012 17.12.2013 13 40879.06 18.12.2020 17.12.2021
6 15041.83 18.12.2013 17.12.2014 14 45750.5 18.12.2021 17.12.2022
7 18382.37 18.12.2014 17.12.2015 15 53491.44 18.12.2022 17.12.2023
8 21857.15 18.12.2015 17.12.2016
If what you want to do is split your results into two side-by-side sets of data, then you will need to pivot your data accordingly.
I can see that is what you're trying to do, but you need to use conditional aggregates to produce the columns.
So you want something like:
WITH your_table AS (SELECT 1 y1, 0 redempamount1, to_date('18/12/2008', 'dd/mm/yyyy') f1, to_date('17/12/2009', 'dd/mm/yyyy') f2 FROM dual UNION ALL
SELECT 2 y1, 3362.54 redempamount1, to_date('18/12/2009', 'dd/mm/yyyy') f1, to_date('17/12/2010', 'dd/mm/yyyy') f2 FROM dual UNION ALL
SELECT 3 y1, 6030.84 redempamount1, to_date('18/12/2010', 'dd/mm/yyyy') f1, to_date('17/12/2011', 'dd/mm/yyyy') f2 FROM dual UNION ALL
SELECT 4 y1, 8873.52 redempamount1, to_date('18/12/2011', 'dd/mm/yyyy') f1, to_date('17/12/2011', 'dd/mm/yyyy') f2 FROM dual UNION ALL
SELECT 5 y1, 15041.83 redempamount1, to_date('18/12/2012', 'dd/mm/yyyy') f1, to_date('17/12/2011', 'dd/mm/yyyy') f2 FROM dual UNION ALL
SELECT 6 y1, 15041.83 redempamount1, to_date('18/12/2013', 'dd/mm/yyyy') f1, to_date('17/12/2011', 'dd/mm/yyyy') f2 FROM dual UNION ALL
SELECT 7 y1, 18382.37 redempamount1, to_date('18/12/2014', 'dd/mm/yyyy') f1, to_date('17/12/2011', 'dd/mm/yyyy') f2 FROM dual UNION ALL
SELECT 8 y1, 21857.15 redempamount1, to_date('18/12/2015', 'dd/mm/yyyy') f1, to_date('17/12/2011', 'dd/mm/yyyy') f2 FROM dual UNION ALL
SELECT 9 y1, 25472.97 redempamount1, to_date('18/12/2016', 'dd/mm/yyyy') f1, to_date('17/12/2011', 'dd/mm/yyyy') f2 FROM dual UNION ALL
SELECT 10 y1, 27359.51 redempamount1, to_date('18/12/2017', 'dd/mm/yyyy') f1, to_date('17/12/2011', 'dd/mm/yyyy') f2 FROM dual UNION ALL
SELECT 11 y1, 31690.65 redempamount1, to_date('18/12/2018', 'dd/mm/yyyy') f1, to_date('17/12/2011', 'dd/mm/yyyy') f2 FROM dual UNION ALL
SELECT 12 y1, 36195 redempamount1, to_date('18/12/2019', 'dd/mm/yyyy') f1, to_date('17/12/2020', 'dd/mm/yyyy') f2 FROM dual UNION ALL
SELECT 13 y1, 40879.06 redempamount1, to_date('18/12/2020', 'dd/mm/yyyy') f1, to_date('17/12/2021', 'dd/mm/yyyy') f2 FROM dual UNION ALL
SELECT 14 y1, 45750.5 redempamount1, to_date('18/12/2021', 'dd/mm/yyyy') f1, to_date('17/12/2022', 'dd/mm/yyyy') f2 FROM dual UNION ALL
SELECT 15 y1, 53491.44 redempamount1, to_date('18/12/2022', 'dd/mm/yyyy') f1, to_date('17/12/2023', 'dd/mm/yyyy') f2 FROM dual)
SELECT MAX(CASE WHEN grp = 1 THEN y1 END) AS y1,
MAX(CASE WHEN grp = 1 THEN redempamount1 END) AS redempamount1,
MAX(CASE WHEN grp = 1 THEN f1 END) AS f1,
MAX(CASE WHEN grp = 1 THEN f2 END) AS f2,
MAX(CASE WHEN grp = 2 THEN y1 END) AS y2,
MAX(CASE WHEN grp = 2 THEN redempamount1 END) AS redempamount2,
MAX(CASE WHEN grp = 2 THEN f1 END) AS f3,
MAX(CASE WHEN grp = 2 THEN f2 END) AS f4
FROM (SELECT y1,
redempamount1,
f1,
f2,
grp,
row_number() OVER (PARTITION BY grp ORDER BY y1) rn
FROM (SELECT y1,
redempamount1,
f1,
f2,
NTILE(2) OVER (ORDER BY y1) grp
FROM your_table))
GROUP BY rn
ORDER BY rn;
Y1 REDEMPAMOUNT1 F1 F2 Y2 REDEMPAMOUNT2 F3 F4
---------- ------------- ----------- ----------- ---------- ------------- ----------- -----------
1 0 18/12/2008 17/12/2009 9 25472.97 18/12/2016 17/12/2011
2 3362.54 18/12/2009 17/12/2010 10 27359.51 18/12/2017 17/12/2011
3 6030.84 18/12/2010 17/12/2011 11 31690.65 18/12/2018 17/12/2011
4 8873.52 18/12/2011 17/12/2011 12 36195 18/12/2019 17/12/2020
5 15041.83 18/12/2012 17/12/2011 13 40879.06 18/12/2020 17/12/2021
6 15041.83 18/12/2013 17/12/2011 14 45750.5 18/12/2021 17/12/2022
7 18382.37 18/12/2014 17/12/2011 15 53491.44 18/12/2022 17/12/2023
8 21857.15 18/12/2015 17/12/2011
However, if you are in 11g and above, you can use the PIVOT command, which I would argue makes your intentions clearer:
SELECT o_y1 AS y1,
o_redempamount1 AS redempamount1,
o_f1 AS f1,
o_f2 AS f2,
t_y1 AS y2,
t_redempamount1 AS redempamount2,
t_f1 AS f3,
t_f2 AS f4
FROM (SELECT y1,
redempamount1,
f1,
f2,
grp,
row_number() OVER (PARTITION BY grp ORDER BY y1) rn
FROM (SELECT y1,
redempamount1,
f1,
f2,
NTILE(2) OVER (ORDER BY y1) grp
FROM your_table))
PIVOT (MAX(y1) AS y1, MAX(redempamount1) AS redempamount1, MAX(f1) AS f1, MAX(f2) AS f2
FOR grp IN (1 AS o, 2 AS t))
ORDER BY rn;

BUG: ORA_00913 Oracle Error - Too many values

The below code is in stored procedure, and they told me to convert it into nested loops and try running it.
insert into PRICEVIEW_RATE_PLAN_PROC (
SSR_CODE
,CORRIDOR_PLAN_ID
,CORRIDOR_PLAN_DESCRIPTION
,USAGE_TYPE
,PRODUCT
,JURISDICTION
,PROVIDER
,RATE_PERIOD
,FLAGFALL
,RATE
,RATEBAND
,NUMSECS
,BAND_RATE
,ACTIVE_DT
,INACTIVE_DT
)
select /*+ use_hash(rate_usage_overrides,corridor_plan_id_values,product_elements,descriptions,jurisdictions,rate_usage_bands_overrides) */
distinct decode(a.corridor_plan_id, 0, '''', (
select c.short_display
from corridor_plan_id_values c
where a.corridor_plan_id = c.corridor_plan_id
)) as SSR_CODE
,a.corridor_plan_id as CORRIDOR_PLAN_ID
,decode(a.corridor_plan_id, 0, '''', (
select d.display_value
from corridor_plan_id_values d
where a.corridor_plan_id = d.corridor_plan_id
)) as CORRIDOR_PLAN_DESCRIPTION
,decode(a.type_id_usg, 0, '''', (
select f.description_text
from usage_types e
,descriptions f
where a.type_id_usg = e.type_id_usg
and e.description_code = f.description_code
)) as USAGE_TYPE
,decode(a.element_id, 0, '''', (
select h.description_text
from product_elements g
,descriptions h
where a.element_id = g.element_id
and g.description_code = h.description_code
)) as PRODUCT
,decode(a.jurisdiction, 0, '''', (
select j.description_text
from jurisdictions i
,descriptions j
where a.jurisdiction = i.jurisdiction
and j.description_code = i.description_code
)) as JURISDICTION
,decode(a.provider_class, 0, '''', (
select k.display_value
from provider_class_values k
where a.provider_class = k.provider_class
)) as PROVIDER
,decode(a.rate_period, '' 0 '', '''', (
select l.display_value
from rate_period_values l
where a.rate_period = l.rate_period
)) as RATE_PERIOD
,(a.FIXED_CHARGE_AMT / 100) + (a.ADD_FIXED_AMT / 10000000) as FLAGFALL
,(a.ADD_UNIT_RATE / 10000000) * 60 as RATE
,b.RATEBAND as RATEBAND
,b.NUM_UNITS as NUMSECS
,(b.UNIT_RATE / 10000000) * 60 as BAND_RATE
,a.ACTIVE_DT as ACTIVE_DT
,a.INACTIVE_DT as INACTIVE_DT
from rate_usage_overrides a
,rate_usage_bands_overrides b
where a.seqnum = b.seqnum(+);
I converted above code to nested loop and please find below converted nested loop and When I try to run this script below, it is prompting me an error: too many values. Can you tell me what exactly problem is
insert into PRICEVIEW_RATE_PLAN_PROC(
SSR_CODE,
CORRIDOR_PLAN_DESCRIPTION,
USAGE_TYPE,
PRODUCT,
JURISDICTION,
PROVIDER,
RATE_PERIOD,
FLAGFALL,
RATE,
RATEBAND,
NUMSECS,
BAND_RATE,
ACTIVE_DT,
INACTIVE_DT
) VALUES (
(select c.short_display AS SSR_CODE from rate_usage_overrides a,corridor_plan_id_values c where a.corridor_plan_id = c.corridor_plan_id),
(select d.display_value AS CORRIDOR_PLAN_DESCRIPTION from rate_usage_overrides a ,corridor_plan_id_values d where a.corridor_plan_id = d.corridor_plan_id),
(select f.description_text AS USAGE_TYPE from rate_usage_overrides a ,usage_types e, descriptions f where a.type_id_usg = e.type_id_usg and e.description_code = f.description_code ),
(select h.description_text AS PRODUCT from rate_usage_overrides a, product_elements g,descriptions h where a.element_id = g.element_id and g.description_code = h.description_code ),
(select j.description_text AS JURISDICTION from rate_usage_overrides a, jurisdictions i,descriptions j where a.jurisdiction = i.jurisdiction and j.description_code = i.description_code),
(select k.display_value AS PROVIDER from rate_usage_overrides a ,provider_class_values k where a.provider_class = k.provider_class),
(select l.display_value AS RATE_PERIOD from rate_usage_overrides a ,rate_period_values l where a.rate_period = l.rate_period),
(select (a.FIXED_CHARGE_AMT/100) + (a.ADD_FIXED_AMT/10000000) AS FLAGFALL from rate_usage_overrides a AS ACTIVE_DT),
(select (a.ADD_UNIT_RATE/10000000) * 60 AS RATE from rate_usage_overrides a),
(select b.RATEBAND AS RATEBAND from rate_usage_bands_overrides b),
(select b.NUM_UNITS AS NUMSECS from rate_usage_bands_overrides b),
(select (b.UNIT_RATE/10000000) * 60 AS BAND_RATE from rate_usage_bands_overrides b),
(select a.ACTIVE_DT,a.seqnum,b.seqnum AS ACTIVE_DT from rate_usage_overrides a, rate_usage_bands_overrides b where a.seqnum = b.seqnum(+)),
(select a.INACTIVE_DT,a.seqnum,b.seqnum AS INACTIVE_DT from rate_usage_overrides a, rate_usage_bands_overrides b where a.seqnum = b.seqnum(+))
Here is your mistake
(select a.ACTIVE_DT,a.seqnum,b.seqnum AS ACTIVE_DT from rate_usage_overrides a, rate_usage_bands_overrides b where a.seqnum = b.seqnum(+)),
(select a.INACTIVE_DT,a.seqnum,b.seqnum AS INACTIVE_DT from rate_usage_overrides a, rate_usage_bands_overrides b where a.seqnum = b.seqnum(+))
both the query will return 3 field but insert specify only one column that's why u are getting this error. and by the way this is not a bug
Run Individual queries with c.corridor_plan_id from 1st query on wards and check at least one query returns more than one value

Resources