Solved

single row subquery returns more then 1 row

Posted on 2013-11-08
2
432 Views
Last Modified: 2013-11-08
/* Formatted on 11/5/2013 3:28:29 PM (QP5 v5.252.13127.32847) */
  SELECT cc.concatenated_segments "GL Account",
         cc.gl_account_type "Account Type",
         NVL (SUM (bal.begin_balance_dr - bal.begin_balance_cr), 0)
            "Begin Balance",
         h.period_name "Period Name"
    FROM gl_code_combinations_kfv cc,
         gl_balances bal,
         apps.gl_je_headers h,
         apps.gl_je_lines l
   WHERE     cc.code_combination_id = bal.code_combination_id
   AND h.period_name = 'JAN-13'
         AND h.je_header_id = l.je_header_id
         AND l.ledger_id = 2947
         AND cc.segment2 = NVL ('I00G15', cc.segment2)
         and (select  trim(substr(fftl.DESCRIPTION, 1,3))
from fnd_flex_Values ffv,
fnd_flex_values_vl ffvv,
fnd_flex_values_tl fftl,
fnd_flex_value_sets ffvs
where ffv.FLEX_VALUE_ID = ffvv.FLEX_VALUE_ID
and ffvv.FLEX_VALUE_ID =fftl.flex_value_id
and ffvs.FLEX_VALUE_SET_NAME ='CCL_ACCOUNTS'
and ffvv.flex_value=cc.segment4
and language='TR')=102
         AND cc.code_combination_id = l.code_combination_id
GROUP BY cc.concatenated_segments, cc.gl_account_type, h.period_name
ORDER BY cc.concatenated_segments


i dont know how to write the query
0
Comment
Question by:pardeshirahul
2 Comments
 

Author Comment

by:pardeshirahul
ID: 39634449
the way i am writing the query is not correct
0
 
LVL 35

Accepted Solution

by:
Mark Geerlings earned 500 total points
ID: 39634470
The only sub-query you have is:
(select  trim(substr(fftl.DESCRIPTION, 1,3))
from fnd_flex_Values ffv,
fnd_flex_values_vl ffvv,
fnd_flex_values_tl fftl,
fnd_flex_value_sets ffvs
where ffv.FLEX_VALUE_ID = ffvv.FLEX_VALUE_ID
and ffvv.FLEX_VALUE_ID =fftl.flex_value_id
and ffvs.FLEX_VALUE_SET_NAME ='CCL_ACCOUNTS'
and ffvv.flex_value=cc.segment4
and language='TR')

So, run that by itself (just remove the parenthesis at the beginning and end.  What does that query by itself return in your system?  Apparently, that returns multiple rows.

For testing, either select some of the other columns also from those views so you can see what other "where" conditions you may need to add to help this query return exactly one row.  Or, add a group operator like this:
select min(trim(substr(fftl.DESCRIPTION, 1,3)))
or
select max(trim(substr(fftl.DESCRIPTION, 1,3)))

to make sure the query returns exactly one row.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
querying by the sum of a column in decimal 7 56
Array of Key/Value Pairs as input to Oracle function 10 53
query in Oracle forms Builder 2 41
Oracle RAC 12c 8 56
Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now