Solved

single row subquery returns more then 1 row

Posted on 2013-11-08
2
453 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

752 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