Solved

single row subquery returns more then 1 row

Posted on 2013-11-08
2
461 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.
Suggested Courses

624 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