Solved

single row subquery returns more then 1 row

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

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

705 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

13 Experts available now in Live!

Get 1:1 Help Now