SQL Query to convert multiple rows to a single row output

I have the following sql query;
SELECT B.ClientID,
B.BillNo, B.[BillDate],
B.CurrencyCode,
B.BAmount
FROM tblCompanyDetails CD
CROSS
APPLY (
SELECT TOP 5 B1.ClientID,
 B1.[BillNumber],
B1.[BillDate], B1.[CurrencyCode] AS CCY,
 B1.[BillAmount]
FROM tblBills B1
WHERE ROUND(B1.[BillAmount],2)<>0
AND B1.ClientID=CD.CompanyID
AS B
WHERE CD.ContactId=235405
ORDER
BY B.ClientID,B.BillNo
DESC
This gives me the following row output;
ClientID
BillNo
BillDate
CurrencyCode
BAmount
94466
425616
2015-04-07
GBP
5000
94466
424517
2015-01-15
GBP
6000
94466
424455
2014-10-15
GBP
4000
However, I would like the ouput to appear like this;
ClientID
BillNo1
BillDate
CCY
BAmount
BillNo2
BillDate
CCY
BAmount
BillNo3
BillDate
CCY
BAmount
94466
 425616
 2015-04-07
 GBP
 5000
 424517
 2015-01-15
 GBP
 6000
 424455
 2014-10-15
 GBP
4000 

I have tried to create a sample based on your question
CREATE TABLE MyTable
ClientID INT ,
BillNo INT,
BillDate DATE,
CurrencyCode varchar(5),
BAmount INT
INSERT INTO MyTable
VALUES (94466,425616,'2015-04-07','GBP',5000),
(94466,424517,'2015-01-15','GBP',6000),
(94466,424455,'2014-10-15','GBP',4000)
Then I have used another table to put ranking in that, you can actually tweak your statement to include rank also
CREATE TABLE RowTable
ClientID INT ,
BillNo INT,
BillDate DATE,
CurrencyCode varchar(5),
BAmount INT,
Ranking INT
INSERT INTO RowTable
SELECT * , ROW_NUMBER() OVER (ORDER BY ClientID) as row
FROM MyTable
Once your data is ready then execute below dynamic query
DECLARE @cols AS NVARCHAR(MAX),
@query AS NVARCHAR(MAX)
select @cols = STUFF((SELECT ',' + QUOTENAME(col+cast(Ranking as varchar(10)))
from RowTable
cross apply
select 'BillNo', 1 union all
select 'BillDate', 2 union all
select 'CurrencyCode', 3 union all
select 'BAmount' , 4
) c (col, so)
group by col, so, Ranking
order by Ranking, so
FOR XML PATH(''), TYPE
).value('.', 'NVARCHAR(MAX)')
,1,1,'')
set @query = 'SELECT ClientId,' + @cols + '
from
select clientid, col+cast(Ranking as varchar(10)) col, value
from RowTable
cross apply
SELECT ''BillNo'', cast(BillNo as varchar(20)) union all
SELECT ''BillDate'', cast(BillDate as varchar(20)) union all
SELECT ''CurrencyCode'', CurrencyCode union all
SELECT ''BAmount'', CAST(BAmount as varchar(10))
) c (col, value)
) x
pivot
max(value)
for col in (' + @cols + ')
) p '
execute sp_executesql @query;
Output: 
Hope this will help. 

Similar Messages

  • How to convert (multiple) rows output to multiple (columns)

    Hii
    I have wierd query. But not sure of how to get result out of it!!!
    My query returns two rows for a query that i have posed.
    Current Result
    10
    20
    Expected Result
    10 20
    My problem here is i wanted the above two values to be stored in two variables in a single select statement.
    If i use a cursor my problem will be solved.But i am not much intrested to use a cursor for a simple select statement.
    is there any possibilty that i can convert the output of two rows to two columns??
    I am using Oracle Release 10.1.0.2.0
    Operating system Windows Xp.
    People here will not appreciate the tags "Urgent". I know that :-(.
    But some how i am forced to use this tag "urgent". Sorry for that.
    If no answers i will in other way have to go to cursor :-(
    Any help will be appreciated.
    Thanks,
    Pavan

    Another solution with model and you don't need a subquery
    SELECT  DEPT ,SUBSTR(LOCATION1,2) LOCATION1, SUBSTR(LOCATION2,2) LOCATION2,SUBSTR(LOCATION3,2) LOCATION3
        FROM   T
        MODEL
          RETURN UPDATED ROWS 
         PARTITION BY ( DEPT )
          DIMENSION BY ( ROW_NUMBER() OVER (PARTITION BY DEPT ORDER BY LOCATION ) AS POSITION )
          MEASURES     ( location,CAST ( LOCATION AS VARCHAR2(15)) AS LOCATION1 ,CAST ( LOCATION AS VARCHAR2(15)) AS LOCATION2,
                                   CAST ( LOCATION AS VARCHAR2(15)) AS LOCATION3 )IGNORE NAV
         RULES
           UPSERT
           ITERATE( 1000)
             UNTIL ( PRESENTV(LOCATION[ITERATION_NUMBER+2],1,0) = 0)
           ( LOCATION1[0] =LOCATION1[0] || CASE WHEN ITERATION_NUMBER+1=1 THEN  ',' || LOCATION1[ ITERATION_NUMBER+1] END,
             LOCATION2[0] =LOCATION2[0] || CASE WHEN ITERATION_NUMBER+1=2 THEN  ',' || LOCATION2[ ITERATION_NUMBER+1] END,
              LOCATION3[0] =LOCATION3[0] || CASE WHEN ITERATION_NUMBER+1=3 THEN  ',' || LOCATION3[ ITERATION_NUMBER+1] END  )
       ORDER BY DEPT
    Demo
    SQL> WITH T AS (   SELECT 'AB' DEPT,'MEB' LOCATION FROM DUAL UNION ALL
      2                SELECT 'AB','MEB1' FROM DUAL UNION ALL
      3                SELECT 'AB','MEB2' FROM DUAL UNION ALL
      4                SELECT 'BC','MEB' FROM DUAL UNION ALL
      5                SELECT 'BC','MEB' FROM DUAL UNION ALL
      6                SELECT 'CD','MEN' FROM DUAL UNION ALL
      7                SELECT 'CD','MEN' FROM DUAL
      8                )
      9  SELECT  DEPT ,SUBSTR(LOCATION1,2) LOCATION1, SUBSTR(LOCATION2,2) LOCATION2,SUBSTR(LOCATION3,2)
    LOCATION3
    10      FROM   T
    11      MODEL
    12        RETURN UPDATED ROWS 
    13       PARTITION BY ( DEPT )
    14        DIMENSION BY ( ROW_NUMBER() OVER (PARTITION BY DEPT ORDER BY LOCATION ) AS POSITION )
    15        MEASURES     ( location,CAST ( LOCATION AS VARCHAR2(15)) AS LOCATION1 ,CAST ( LOCATION AS
    VARCHAR2(15)) AS LOCATION2,
    16             CAST ( LOCATION AS VARCHAR2(15)) AS LOCATION3 )IGNORE NAV
    17       RULES
    18         UPSERT
    19         ITERATE( 1000)
    20           UNTIL ( PRESENTV(LOCATION[ITERATION_NUMBER+2],1,0) = 0)
    21         ( LOCATION1[0] =LOCATION1[0] || CASE WHEN ITERATION_NUMBER+1=1 THEN  ',' || LOCATION1[ I
    TERATION_NUMBER+1] END,
    22        LOCATION2[0] =LOCATION2[0] || CASE WHEN ITERATION_NUMBER+1=2 THEN  ',' || LOCATION2[ ITER
    ATION_NUMBER+1] END,
    23        LOCATION3[0] =LOCATION3[0] || CASE WHEN ITERATION_NUMBER+1=3 THEN  ',' || LOCATION3[ ITER
    ATION_NUMBER+1] END  )
    24     ORDER BY DEPT
    25     /
    DE LOCATION1      LOCATION2      LOCATION3
    AB MEB            MEB1           MEB2
    BC MEB            MEB
    CD MEN            MEN
    SQL>
    SQL> 

  • Convert  multiple rows into single rows for the respective index name

    Dear Experts,
                             I want to convert  multiple rows into single rows for the respective index name,
                            Here is my query.
    SELECT user_tables.table_name, user_indexes.index_name, user_ind_columns.column_name
    FROM user_tables
    JOIN user_indexes on user_indexes.table_name = user_tables.table_name
    join USER_IND_COLUMNS on USER_INDEXES.INDEX_NAME = USER_IND_COLUMNS.INDEX_NAME
    where user_indexes.index_name not like '%PK%' AND user_ind_columns.column_name NOT LIKE '%SYS%'
    ORDER BY user_tables.table_name,user_indexes.index_name;
    Result of previous query
    TABLE_NAME
    INDEX_NAME
    COLUMN_NAME
    T1
    IDX_ACCNTYPCFG1
    ENABLE_SERVICE
    T1
    IDX_ACCTTYPCFG1
    ACC_CODE
    T1
    IDX_ACCTTYPCFG1
    ACCTYPE
    T2
    IDX_ACCTTYPCFGAPP1
    ACCTYPE
    T3
    IDX_ACTLG1
    MOBILE_NO
    T3
    IDX_ACTLG1
    ID
    Desired output required is
    TABLE_NAME
    INDEX_NAME
    COLUMN_NAME
    T1
    IDX_ACCNTYPCFG1
    ENABLE_SERVICE,ACC_CODE,ACCTYPE
    T2
    IDX_ACCTTYPCFGAPP1
    ACCTYPE
    T3
    IDX_ACTLG1
    ACCTYPE,MOBILE_NO
    please help.

    Maybe
    with
    user_tables as
    (select 'T1' table_name,'IDX_ACCNTYPCFG1' index_name,'ENABLE_SERVICE' column_name from dual union all
    select 'T1','IDX_ACCTTYPCFG1','ACC_CODE' from dual union all
    select 'T1','IDX_ACCTTYPCFG1','ACCTYPE' from dual union all
    select 'T2','IDX_ACCTTYPCFGAPP1','ACCTYPE' from dual union all
    select 'T3','IDX_ACTLG1','MOBILE_NO' from dual union all
    select 'T3','IDX_ACTLG1','ID' from dual
    select table_name,
           case index_name when 'IDX_ACCNTYPCFG1' then 'IDX_ACCTTYPCFG1' else index_name end index_name,
           listagg(case column_name when 'ID' then 'ACCTYPE' else column_name end,',') within group (order by null) column_name
      from user_tables
    group by table_name,case index_name when 'IDX_ACCNTYPCFG1' then 'IDX_ACCTTYPCFG1' else index_name end
    TABLE_NAME
    INDEX_NAME
    COLUMN_NAME
    T1
    IDX_ACCTTYPCFG1
    ACCTYPE,ACC_CODE,ENABLE_SERVICE
    T2
    IDX_ACCTTYPCFGAPP1
    ACCTYPE
    T3
    IDX_ACTLG1
    ACCTYPE,MOBILE_NO
    Regards
    Etbin

  • Need a sql query to get multiple dates in rows

    Hi All,
    i need a query to get dates for last 7 days and each dates should be in one row...
    but select sysdate from dual..gives one row...
    Expexcted Output
    Dates:
    01-oct-2013
    30-sep-2013
    29-sep-2013
    28-sep-2013
    27-sep-2013
    26-sep-2013

    Hi,
    Do you mean that you want all 7 dates together on 1 row?
    Here's one way:
    SELECT LISTAGG ( TO_CHAR ( SYSDATE + 1 - LEVEL
                              , 'DD-Mon-YYYY'
                    ) WITHIN GROUP (ORDER BY LEVEL)    AS txt
    FROM    dual
    CONNECT BY LEVEL <= 7
    This is an example of String Aggregation, that is, taking a column on multiple rows, and concatenating all the values (however many htere happen to be) into 1 big string column 1 row.
    Like everything else, exactly how to do it depends on your Oracle version.
    For more on String Aggregation, including differetn techniques for different versions, see http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php
    Message was edited by: FrankKulash
    Sorry, I mis-read the question.

  • Need sql query to convert rows to columns

    Im using oracle 11g.
    I have data in a table as below: Column names are type,month,percentage
    TYPE      MONTH   PERCENTAGE
    A1         JAN-2013     100
    A2         JAN-2013     100
    A3         JAN-2013     95
    A4         JAN-2013     98
    A5         JAN-2013     99
    A6         JAN-2013     90
    A7         JAN-2013     92
    A1         FEB-2013     100
    A2         FEB-2013     99
    A3         FEB-2013     88
    A4         FEB-2013     67
    A5         FEB-2013     98
    A6         FEB-2013     95
    A7         FEB-2013     84
    The desired output using a sql query is as below
    TYPE     JAN-2013     FEB-2013
    A1         100             100
    A2         100             99
    A3         95               88
    A4         98               67
    A5         99               98
    A6         90               95
    A7         92               84

    Try this:
    select * from table_name
    PIVOT(   max(Percentage)
                     for MONTH
                     in ('JAN-2013','FEB-2013')
                     ) ;with data
    with t(TYPE,MONTH,PERCENTAGE) as
    SELECT 'A1', 'JAN-2013', 100
      FROM DUAL
    UNION ALL
    SELECT 'A2', 'JAN-2013', 100
      FROM DUAL
    UNION ALL
    SELECT 'A3', 'JAN-2013', 95
      FROM DUAL
    UNION ALL
    SELECT 'A4', 'JAN-2013', 98
      FROM DUAL
    UNION ALL
    SELECT 'A1', 'FEB-2013', 100
      FROM DUAL
    UNION ALL
    SELECT 'A2', 'FEB-2013', 99
      FROM DUAL
    UNION ALL
    SELECT 'A3', 'FEB-2013', 88
      FROM DUAL
    UNION ALL
    SELECT 'A4', 'FEB-2013', 67
      FROM DUAL
    select * from t PIVOT(   max(Percentage)
                     for MONTH
                     in ('JAN-2013','FEB-2013')
                     ) ;

  • Query to return multiple rows

    Hi all,
    I've a requirement where in I've to get multiple rows from a query.
    The resultset should be something like this:
    SELECT A
    FROM dual;
    A
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    Thanks in anticipation
    RK Raju

    I'm not completely certain I understand the question. Just in case you're asking for something as simple as this ...
    select rownum from all_objects where rownum <= 10;You didn't say what version you were using either (shame on you). You could use a collection or a pipeline depending on your version ...
    create or replace type ttab_number is table of number;
    create or replace function f_collection
        return ttab_number is
        tab_number ttab_number := ttab_number();
    begin
        for i in 1 .. 10 loop
            tab_number.extend;
            tab_number(tab_number.count) := i;
        end loop;
        return tab_number;
    end f_collection;
    select *
    from table(f_collection)
    create or replace function f_pipeline
        return ttab_number
        pipelined is
    begin
        for i in 1 .. 10 loop
            pipe row(i);
        end loop;
        return;
    end f_pipeline;
    show errors
    select *
    from table(f_pipeline)

  • SQL Query updateable report with row selector. Update process.

    I have a SQL Query updateable report with the row selector(s).
    How would I identify the row selector in an update process on the page.
    I would like to update certain columns to a value of a select box on the page.
    Using the basic:
    UPDATE table_name
    SET column1=value
    WHERE some_column=some_value
    I would need to do:
    UPDATE table_name
    SET column1= :P1_select
    WHERE [row selector] = ?
    Now sure how to identify the [row selector] and/or validate it is checked.
    Thanks,
    Bob

    I don't have the apex_application.g_f01(i) referenced in the page source...In the page source you wouldn't find anything by that name
    Identify the tabular form's checkbox column in the page(firebug/chrome developer panel makes this easy)
    It should be like
    &lt;input id=&quot;...&quot; value=&quot;&quot; type=&quot;checkbox&quot; name=&quot;fXX&quot; &gt;we are interested in the name attribute , get that number (between 01 and 50)
    Replace that number in the code, for instance if it was f05 , the code would use
    apex_application.g_f05
    --i'th checked record' primary keyWhen you loop through a checkbox array, it only contains the rows which are checked and it is common practice to returns the record's primary key as the value of the checkbox(available as the the i'th array index as apex_application.g_f05(i) , where i is sequence position of the checked row) so that you can identify the record.

  • Trying to convert multiple rows into multipe columns within a single row

    I am trying to convert data from multiple rows into multiple columns. Let me see if I can paint the picture for you.
    Here is a sample of the table i am trying to read from:
    Company Name Account
    1 Sam 123
    1 Sam 234
    1 Joe 345
    1 Sue 789
    1 Sue 987
    1 Sue 573
    I am trying to put this into a View that would have the data represented as such:
    Company Name Acct1 Acct2 Acct3 Acct4
    1 Sam 123 234 <null> <null>
    1 Joe 345 <null> <null> <null>
    1 Sue 789 987 573 <null>
    Many thanks in advance for your help!

    test@XE> --
    test@XE> with t as (
      2    select 1 as company, 'Sam' as name, 123 as account from dual union all
      3    select 1, 'Sam', 234 from dual union all
      4    select 1, 'Joe', 345 from dual union all
      5    select 1, 'Sue', 789 from dual union all
      6    select 1, 'Sue', 987 from dual union all
      7    select 1, 'Sue', 573 from dual)
      8  --
      9  select company,
    10         name,
    11         max(case when rn = 1 then account else null end) as acct1,
    12         max(case when rn = 2 then account else null end) as acct2,
    13         max(case when rn = 3 then account else null end) as acct3,
    14         max(case when rn = 4 then account else null end) as acct4
    15    from (select company,
    16                 name,
    17                 account,
    18                 row_number() over (partition by company, name order by 1) as rn
    19            from t)
    20   group by company, name;
       COMPANY NAM      ACCT1      ACCT2      ACCT3      ACCT4
             1 Joe        345
             1 Sam        234        123
             1 Sue        573        789        987
    3 rows selected.
    test@XE>
    test@XE>isotope

  • Print Child SQL which is returning multiple rows to single colum.

    I have a requirement to print both Parent and Child SQLs rows to single row.
    For Ex:
    Parent row is returning single row
    Id, Name, Primary Rate.
    101, LName,FName ,30
    Child row is returning multiple rows
    Id, Name, Secondary Rate
    101, LName,FName,15
    101, LName,FName,10
    The end result should be
    101,LName,FName,30,15,10
    Any suggestions please?

    Below is the XML TAG
    <LIST_EMPLOYEERATE>
    <EMPLOYEERATE>
    <EMPNUMBER>112</EMPNUMBER>
    <EMPNAME>Aaron</EMPNAME>
    <PAYRATE>38.09</PAYRATE>
    <JOBNAME>Technician</JOBNAME>
    <EMPTYPE>Salary</EMPTYPE>
    <LIST_ADDRATE>
    <ADDRATE>
    <ADDPAYRATE>26</ADDPAYRATE>
    </ADDRATE>
    <ADDRATE>
    <ADDPAYRATE>7.9</ADDPAYRATE>
    </ADDRATE>
    </LIST_ADDRATE>
    </EMPLOYEERATE>
    </LIST_EMPLOYEERATE>
    The Result should be (assume this is going onto excel spread sheet)
    EmpNum EmpName Rate EmpType Rate1 Rate2
    112 Aaron 38.09 Salary 26 7.9
    Using @inline we are able to get 26 and 7.9 on the same line, but how to push 7.9 to next column?
    Thanks!

  • Unable to copy the sql data in excel multiple rows

    Hi friends,
    when i am paste the sql table data in excel,it's not adding multiple rows,it's addingsingle row.,
    i want to paste data in to multiple rows

    So you have a table that contains some text and you want to copy the text to Excel sheet.I would use Ssis package and try edit the excel sheet to multiple text allowance.
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Convert Multiple Rows in a single Comma Seprated value

    Is is possible to convert miltiple rows in a single value by concatenating each row value in OBIEE. I think OI had seem a blog post relted to this by I'm not able to to find it again. Basically Here is what I would like to do:
    Customer number Location
    101 IL
    101 NY
    101 PA
    102 TX
    102 CA
    Convert this to
    101 IL, NY, PA
    102 TX,CA
    Can someone please let me know if this is possible and how to make it work.
    Thanks you for the help in advance.

    You can do this by creating a DB function,
    Check this link
    Re: Horizontal value display
    Thanks,
    Vino

  • SQL Query to Fetch 500 Rows at once

    Hi,
      Due to performance issue of the SQL query takes lot of time to execute. I tried modifying the code as mentioned below but it is not working to fetch when search is implemented. Actually data is more than 1 Million Records so it takes lot of time to query the data.
    SELECT DISTINCT
    IMV.*,
      nvl(imv.party_name,imv.bill_to_name) "Bill To Name",
      Imv.Ship_To_City "Reseller City",
      Imv.Ship_To_State "Reseller State",
      Edb2_Global.Country_Name_Theater(Imv.Ship_To_Country ,'COUNTRY') "Reseller Country",
      Edb2_Global.Country_Name_Theater(Imv.Ship_To_Country ,'THEATER') "Reseller Theater",
      Cl.City "Customer City",
      Cl.State "Customer State",
      EDB2_GLOBAL.COUNTRY_NAME_THEATER(CL.COUNTRY,'COUNTRY') "Customer Country",
      EDB2_GLOBAL.COUNTRY_NAME_THEATER(CL.COUNTRY,'THEATER') "Customer Theater"
    FROM IB_SUPPORT_CONTRACTS_MV IMV,
      customer_products cp,
      customer_locations cl
    WHERE
    UPPER(TRIM(IMV.SERIAL_NUMBER)) = UPPER(TRIM(CP.PRODUCT_SERIAL_NUMBER(+) ) )
    AND CP.LOCATION_ID                     = CL.LOCATION_ID(+)
    AND ROWNUM <= 501
    Please suggest me how to improve the performance of the query.
    Thanks
    Sudhir

    Hi,
    As mentioned already, this condition is really hurting performance:
    UPPER(TRIM(IMV.SERIAL_NUMBER)) = UPPER(TRIM(CP.PRODUCT_SERIAL_NUMBER(+) ) )
    Could you trim and capitalize the serial numbers before storing them?  Do you really need to remember exactly how the serial numbers were entered?  If you really do, then store it in one column, and store UPPER (TRIM (serial_number)) in a different column.  Starting in Oracle 11, this could be a virtual column; in any version (7 or higher), it could be maintained by a trigger.  Failing that, create a function-based index on UPPER (TRIM (serial_number)).

  • SQL query to assign multiple concurrent programs to concurrent manager.

    Hello,
    Do you have any script to assign a list of concurrent Program to distinct  Concurrent Managers . Actually there are more than 100 programs need to be assigned to manager.ut
    We can do it from front end,but it will take quite long time to finish this task.
    Could you please help me on this.
    Thanks & Regards,
    Saroj.

    What are the details do i need to check before assign them to Custom Managers.
    What do you mean by details you need to check?
    Kindly provide me a sql query to get all the details before proceeding to assigning managers.
    Concurrent programs definitions can be found in the following tables/views:
    FND_CONCURRENT_PROGRAMS
    http://etrm.oracle.com/pls/et1211d9/etrm_pnav.show_object?c_name=FND_CONCURRENT_PROGRAMS&c_owner=APPLSYS&c_type=TABLE
    FND_CONCURRENT_PROGRAMS_TL
    http://etrm.oracle.com/pls/et1211d9/etrm_pnav.show_object?c_name=FND_CONCURRENT_PROGRAMS_TL&c_owner=APPLSYS&c_type=TABLE
    FND_CONCURRENT_PROGRAMS_VL
    http://etrm.oracle.com/pls/et1211d9/etrm_pnav.show_object?c_name=FND_CONCURRENT_PROGRAMS_VL&c_owner=APPS&c_type=VIEW
    Thanks,
    Hussein

  • How to convert multiple rows into colmun data?

    Hi all
    ODI has fuction that covert multiple rows form a file into colmun data?
    Source:customer.txt
    001,Scott
    001,Man
    001,23
    002,Lincon
    002,Man
    002,21
    objective Target:customer
    ID Name Sex Age
    001 Scott Man 23
    002 Lincon Man 21
    If there is no this fuction,how can I do this in ODI?
    Thanks in advance.
    Agui

    Hi, Sanjeev,
    What you requested is called String Aggregation.
    Like most other things, the best way to do it depends on your version of Oracle.
    The following site shows several different ways to do string aggregation:
    http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php'
    The user-defined function (often called STRAGG) that Charles mentioned is my favorite, in versions between 9.1 and 11.1.

  • Querying view gives multiple rows

    I have a query that returns duplicate rows (5) when I write the query this way:
    "Select *
    from view v
    , table_A a
    where v.key = a.key"
    However, if I write the query this way, the correct data is returned, i.e., only one row.
    "Select *
    from (select * from view v)
    ,table_A a
    where v.key = a.key"
    It also works correctly if I put the in-line view in the select portion of the select statement.
    Any ideas?
    Thank you for your help,
    Tricia

    With the second query, I get "ORA-00904: "V"."KEY": invalid identifier". Are you sure that it ran ok for you? v.key is out of scope in the where clause...
    If I label the subselect as v, I get the same result as the first query - 5 rows.
    Message was edited by:
    Boneist
    (I can't spell)

Maybe you are looking for

  • What's wrong  with the role?

    I create URL iviews and pages, preview , it is OK. Then I create workset, role, and assign to a user. When I login with the account, I can't see the pages. Anybody help?

  • Oracle 10g ODBC driver (ver 10.1.0.2) :  SQLConnect Hangs

    hi, We have a Win32 multithreaded app which uses the given 10g driver, but intermittently all the threads hang on SqlConnect. After running Adplus the call stack that we get , always point to oranls10. This is the call stack from the last time the se

  • Slideshows do not play customised music in iPhoto 11

    I updated  i Mac and now have i Photo 11 with Mac OS X 10.6.8. Choosing slideshow in albums and books gives you an option to stop the show with cursor and choose music. But I have the problem that this pop up window is dead. I cannot bring music from

  • Start and stop time differ from iPod to computer

    I joined 2 .mp3 together using a music edtion program (the first song was 4:30 and the second one 3:40) making one long sound file. The stop time for the song in iTunes is set at 8:10. When I play the song on my iPod, it comes to a complete halt at 4

  • HT2506 Preview is not working.  How can I reload the program?

    When I open up the Preview Program the little ball keeps spinning and will not load.  Would like to delete any files in the program that are there, but since the program won't load I can't get anywhere.