Home » SQL & PL/SQL » SQL & PL/SQL » ora 00913
ora 00913 [message #244712] |
Wed, 13 June 2007 21:08 |
kilyas
Messages: 24 Registered: March 2007
|
Junior Member |
|
|
The following query is returning error ORA-00913: too many values
could somebody explain what might be the reason
select to_char(record_date,'YYYY-MM-DD') as "name",
decode('U','U','Upgrade','D','Downgrade') as "direction",
'ALL' as "portfolio_id"
,
avg(total_mv) as "marketValue",
avg(total_sv) as "statValue",
avg(total_gv) as "gaapValue",
avg(total_par) as "par",
count(*) as "naic_shifts",
(
select ccmsectype as "name",
decode('U','U','Upgrade','D','Downgrade') as "direction",
sum(marketvalue) as "marketValue",
sum(statvalue) as "statValue",
sum(gaapvalue) as "gaapValue",
sum(par) as "par",
count(*) as "naic_shifts"
from naic_up_down_view inner where
outer.record_date = inner.record_date and
(
(
(DECODE ('U','U',1,0)=1 AND ORG_NAIC>CURRENT_NAIC)
OR (DECODE('U', 'D' , 1, 0) = 1 AND ORG_NAIC < CURRENT_NAIC)
)
) group by ccmsectype
)
from naic_up_down_view outer
where
(
( decode ('U','U',1,0)=1 and org_naic>current_naic) OR
( decode ('U','D',1,0)=1 and org_naic<current_naic)
)
group by record_date
|
|
|
|
|
Re: ora 00913 [message #244888 is a reply to message #244759] |
Thu, 14 June 2007 08:32 |
kilyas
Messages: 24 Registered: March 2007
|
Junior Member |
|
|
sorry about that posting it again in the code tags.
select to_char(record_date,'YYYY-MM-DD') as "name",
decode('U','U','Upgrade','D','Downgrade') as "direction",
'ALL' as "portfolio_id"
,
avg(total_mv) as "marketValue",
avg(total_sv) as "statValue",
avg(total_gv) as "gaapValue",
avg(total_par) as "par",
count(*) as "naic_shifts",
(
select ccmsectype as "name",
decode('U','U','Upgrade','D','Downgrade') as "direction",
sum(marketvalue) as "marketValue",
sum(statvalue) as "statValue",
sum(gaapvalue) as "gaapValue",
sum(par) as "par",
count(*) as "naic_shifts"
from naic_up_down_view inner where
outer.record_date = inner.record_date and
(
(
(DECODE ('U','U',1,0)=1 AND ORG_NAIC>CURRENT_NAIC)
OR (DECODE('U', 'D' , 1, 0) = 1 AND ORG_NAIC < CURRENT_NAIC)
)
) group by ccmsectype
)
from naic_up_down_view outer
where
(
( decode ('U','U',1,0)=1 and org_naic>current_naic) OR
( decode ('U','D',1,0)=1 and org_naic<current_naic)
)
group by record_date
Here I ahve tried to merge the two queries but its not gonna work since in the inner one returns multiple fields, I have not been able to figure out how I can merge the two in a neat working way.
|
|
|
|
Re: ora 00913 [message #245060 is a reply to message #244888] |
Fri, 15 June 2007 01:35 |
flyboy
Messages: 1903 Registered: November 2006
|
Senior Member |
|
|
Quote: | 8. Provide DDL (CREATE TABLE, etc.) as appropriate instead of listing the table structure. It'll help people setting up a test set (yes, some people really do that)
9. Provide INSERT statements for sample data instead of pasting in or mocking up the results of a SELECT statement.
10. Provide your expected result set.
|
As you did not provide anything from the above list and I have no idea about the result you expect, I may just guess the solution you need.
UNION ALL for row union.
FULL OUTER JOIN using name(?) for column join.
|
|
|
Goto Forum:
Current Time: Tue Dec 03 12:39:46 CST 2024
|