Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

single row subquery returns more then 1 row

Posted on 2013-11-08
2
Medium Priority
?
463 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 2000 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
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…
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

688 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