Query (connect by/string agregation)

Hi
Can anybody give me an example of query
ID VAL
1 A
1 B
1 C
Output: 'A,B,C'
Thanks.
Edited by: Bolev on Feb 3, 2010 5:10 PM

Hi,
Pivot produces separate columns for each val, and you have to know how many there will be.
String Aggregation provides one column, and does not need to know how many vals there will be:
WITH     got_rnum     AS
     SELECT     id
     ,     val
     ,     ROW_NUMBER () OVER ( PARTITION BY  id
                               ORDER BY          val
                       ) AS rnum
     FROM    table_x
SELECT     id
,     LTRIM ( SYS_CONNECT_BY_PATH (val, ',')
           )     AS val_list
FROM     got_rnum
WHERE     CONNECT_BY_ISLEAF     = 1
START WITH     rnum     = 1
CONNECT BY     rnum     = PRIOR rnum + 1
     AND     id     = PRIOR id
;

Similar Messages

  • Query stats substitution strings on IR region

    Hello,
    Are the query stats substitution strings, like #ROWS_FETCHED#, #TOTAL_ROWS#, #FIRST_ROW_FETCHED# and #LAST_ROW_FETCHED#, should be active in an IR region?
    Currently, it seems they are not active, and I’m asking if it’s intentional or a bug.
    Thanks,
    Arie.

    Hi Marco,
    Thanks on your reply, and the enhancement request.
    In the meantime, can you think of a work around? I’m trying to derived a row (serial) index on a paginated view, using ROWNUM. In classic report, you can subtract the current ROWNUM from the #FIRST_ROW_FETCHED#.
    Thanks,
    Arie.

  • "Could Not Find Installable ISAM" While Refreshing Access Query Connection

    This error occurs when an Excel 2010 client attempts to refresh a connection to a Microsoft Access DB (*.accdb file) query.
    This query was previously working in Excel 2010, but stopped working the first time Access 2013 was used to save the database file.  The query remains working perfectly from an Excel 2013 client.
    Given the above, I don't think it is an issue with the connection string:
    Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;Data Source=W:\Data\SLA\Contacts.accdb;Mode=Share Deny Write;Extended Properties="";Jet OLEDB:System database="";Jet OLEDB:Registry Path="";Jet OLEDB:Engine Type=6;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Complex Data=False;Jet OLEDB:Bypass UserInfo Validation=False;Jet OLEDB:Limited DB Caching=False;Jet OLEDB:Bypass ChoiceField Validation=False
    From a client's machine that is using Office 2010, I opened the DB in Access and executed the query fine.  Switching back to the Excel file that has the connection I noted it still failed.
    So, still in Excel 2010, I created a new workbook and setup a new fresh connection to the DB.  It worked fine.  So I compared the connection string it built and it was different.  So it's down to this:
    And one other example from a different Excel workbook connecting to a different query in the same DB. Same issue.  Whatever connection string 2013 Excel generates, is not backward-compatible with Excel 2010:
    Shawn Keene

    Thank for your feedback, Shawn.
    I have no idea why we would get the such error when we save the db via Access 2013.  Adn as my mind this problem is data platform
    relevant. We may post a thread to post a thread to the following forum to get more help.
    http://social.msdn.microsoft.com/Forums/en-US/home?category=dataplatformdev Data platform
    http://social.msdn.microsoft.com/Forums/office/en-US/home?forum=accessdev  Access for Developers
    Cheers,
    Tony Chen
    Forum Support
    Come back and mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback on our support, please contact
    [email protected]

  • Power Query connection to Web Page refreshable?

    Hi all,
    I know you can add PQ connections to the Data Management Gateway and have them be refreshable in the cloud. I noticed they recently began supporting SharePoint List connections. For my particular case, I am pulling in data from our SharePoint, but I
    cannot pull it into PQ with the SharePoint List feature; the table I need does not show up. Maybe it is not set up as a list? Anyway, when I use the website feature in PQ, I can type the address and get the info I need from SP. However, the connection
    string doesn't appear to work in Data Management Gateway. Is it not yet supported? I'd imagine that refreshing from a website would be one of the easier methods.
    What exactly is a SharePoint list, then? When I use out root URL for SP, it pulls back some tables, but not nearly as many as I'd imagine.
    Thanks for the input!
    Mark

    Mike,
    Isn't this just a list module in SharePoint?
    SharePoint Lists are supported as a data source in Power Query:
    http://office.microsoft.com/en-001/excel-help/introduction-to-microsoft-power-query-for-excel-HA104003940.aspx
    Info on Scheduled Data Refresh:
    http://office.microsoft.com/en-001/office365-sharepoint-online-enterprise-help/schedule-data-refresh-for-workbooks-in-power-bi-for-office-365-HA104180761.aspx#_Toc388608196
    Thanks! 
    Ed Price, Azure & Power BI Customer Program Manager (Blog,
    Small Basic,
    Wiki Ninjas,
    Wiki)
    Answer an interesting question?
    Create a wiki article about it!

  • SQL query for empty string

    I am trying to execute the following SQl query, SELECT * FROM Failure WHERE ID = '123' AND RepairAction = ' ';, using the DB Tools Execute Query.vi. This query never finds the record in my database. My database contains a record where the ID filed contains the value of '123' and the RepairAction field is an empty string. If I remove the 'AND RepairAction ' ';' text from my query statement, the record is found. I believe my problem is that I am not using the correct syntax to describe and empty string. I have tried the following: '', ' ', "", " ", and NULL as empty string arguments, and none of these work.
    I was hoping someone might be able to tell me what the correct syntax is for an empty string or if there is another approach I need to take.
    Thank you in advance for your help,
    Jim
    Solved!
    Go to Solution.

    Hi,
    While creating your table "Failure", was the column "ID" delclared as intiger or varchar? If it is intiger and you use '123' , it wont return the results. You will have to try without the inverted comas ' '.
    Regards,
    Nitzz
    (Giver Kudos to good Answers, Mark it as a solution if your problem is Solved)

  • BI Publisher Report Query Error: "character string buffer too small"

    Using apex.oracle.com, I am trying to make a Report Query (Shared Components > Report Queries) based on many columns (around 60).
    When I enter my SQL in the "Source Query" Text Area and then click Test Report I get the following error:
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small In order to try to make the simplest test case possible for this, I then tried entering SQL selecting just from DUAL.
    The following SQL fails with the error mentioned above.
    SELECT
    'wibble' as a
    ,'wibble' as b
    ,'wibble' as c
    ,'wibble' as d
    ,'wibble' as e
    ,'wibble' as f
    ,'wibble' as g
    ,'wibble' as h
    ,'wibble' as i
    ,'wibble' as j
    ,'wibble' as k
    ,'wibble' as l
    ,'wibble' as m
    ,'wibble' as n
    ,'wibble' as o
    ,'wibble' as p
    ,'wibble' as q
    ,'wibble' as r
    ,'wibble' as s
    ,'wibble' as t
    ,'wibble' as u
    ,'wibble' as v
    ,'wibble' as w
    ,'wibble' as x
    ,'wibble' as y
    ,'wibble' as z
    ,'wibble' as ab
    ,'wibble' as ac
    ,'wibble' as ad
    ,'wibble' as ae
    ,'wibble' as af
    ,'wibble' as ag
    ,'wibble' as ah
    ,'wibble' as ai
    ,'wibble' as aj
    ,'wibble' as ak
    ,'wibble' as al
    ,'wibble' as am
    ,'wibble' as an
    ,'wibble' as ao
    ,'wibble' as ap
    ,'wibble' as aq
    ,'wibble' as ar
    ,'wibble' as at
    ,'wibble' as au
    ,'wibble' as av
    FROM dualRemoving the last column from this SQL query (bringing the total number of columns down to 45) as follows and then clicking "Test Report" works successfully.
    SELECT
    'wibble' as a
    ,'wibble' as b
    ,'wibble' as c
    ,'wibble' as d
    ,'wibble' as e
    ,'wibble' as f
    ,'wibble' as g
    ,'wibble' as h
    ,'wibble' as i
    ,'wibble' as j
    ,'wibble' as k
    ,'wibble' as l
    ,'wibble' as m
    ,'wibble' as n
    ,'wibble' as o
    ,'wibble' as p
    ,'wibble' as q
    ,'wibble' as r
    ,'wibble' as s
    ,'wibble' as t
    ,'wibble' as u
    ,'wibble' as v
    ,'wibble' as w
    ,'wibble' as x
    ,'wibble' as y
    ,'wibble' as z
    ,'wibble' as ab
    ,'wibble' as ac
    ,'wibble' as ad
    ,'wibble' as ae
    ,'wibble' as af
    ,'wibble' as ag
    ,'wibble' as ah
    ,'wibble' as ai
    ,'wibble' as aj
    ,'wibble' as ak
    ,'wibble' as al
    ,'wibble' as am
    ,'wibble' as an
    ,'wibble' as ao
    ,'wibble' as ap
    ,'wibble' as aq
    ,'wibble' as ar
    ,'wibble' as at
    ,'wibble' as au
    FROM dualSo the question is: Is there a hard-coded limit of 45 columns for a Source Query? Or is there something else causing this error message?
    (For information in the above example I have "Use Generic Report Layout" selected and the output format set to "PDF")
    Thanks very much in advance for any comments or suggestions,
    Andy

    Thanks for the suggestion Simon.
    I just created a view based on the 46-column SELECT statement from dual above and then set "SELECT * FROM myview" as the Source Query.
    Unfortunately I get exactly the same error.
    Thanks,
    Andy

  • Help with Oracle Connection- "Input string was not in a correct format"

    Hello, can some one, anyone please help me. I have a simple VS 2005 C# application that connects to oracle. I've set it up to take the username, password and tnsname as arguments. I am using Client 9i, version 9.2.0.401 of Oracle.DataAccess.dll, and .NET Framework 2.0.
    It works fine when I run it from VS 2005, I have also set up a test machine w/o VS 2005 and ran my install package and it runs fine. I sent it to one of my co-workers and when he tries it the OracleConnection obect fails with the error.
    "Input string was not in a correct format"
    strange in that it is not an ORA error, just the identifed text!?
    Here is the code:
    ## begin code
    OracleConnection dbc = new OracleConnection();
    string sConnectString = "User Id=" + username.ToString() + ";Password=" + password.ToString() + ";Data Source=" + tnsname.ToString();
    dbc.ConnectionString = sConnectString.ToString();
    MessageBox.Show("Attempting to Connect to Oracle");
    dbc.Open();
    MessageBox.Show("Connected to Oracle: " + dbc.ServerVersion);
    ## end code
    Pretty basic, what could be going on?
    Since this only happens with an installation, I put in the message boxes to verify exactly where it chokes. I get the first message box, then an error with the identified text. I've seen a number of posts regarding input string format problems, but not a one dealing with OracleConnection.Open(). I added all the ToString() calls just to make sure everything was a string but it did not change the end result.
    Anyone? Thanks In advance!
    Eric S.

    Hello,
    well, i got a message "...string not wellformed format...", too.
    If you have defined the parameters as string, you don't need the additonal "ToString()". Please ckeck your tnsnames -string. Try to debug this. I believe you have copy the format from the tnsnames.ora and there you have much brackets.
    For example, two code snippets:
    As datasource i use <Server>:<Port>/<Instance>
    try
    string FDsn ="User Id="+FDbUser+";Password="+FDbPwd;
    FDsn +=";Data Source=wth5:1521/Ora9.wth5";
    FConn = new OracleConnection(FDsn);
    FConn.Open();
    if (FConn.State == ConnectionState.Open )
         FConn.Close();
    catch (Exception ex)
         FStateMsg = "Connection to database failed. Check Configuration in parameter: ConnectionString. " + ex.Message;
    Above i connect to a Ora 9.2.0.1
    by using
    FDsn +=";Data Source=wth5:1522/XE";
    i connect to an OraExpress database on the same machine.
    My Oracle.dataAccess.dll ist the newest, 10.2.... and it runs under Framework 1.1.x and Framework 2.x
    I'll hope it will help you. Best regards!

  • Query for matching strings

    Hi, I am using a prepared statement and how can I perform string matching using that?
    For example, I have
    PreparedStatement pstat = con.prepareStatement( new String(sql))
    what should my sql String look like to query for strings containing "ab"
    so when the executeQuery() is called,
    I get results such as "abcd", "abcdcdc","ccccabccc"??
    Thanks a lot,

    try somethink like this:
    SELECT * FROM table_name WHERE column_name LIKE
    '%ab%'
    or
    SELECT * FROM table_name WHERE column_name LIKE ?
    providing "%ab%" as parameterAdding to that - you MUST do the % yourself and then use setString. The following will NOT work....
    SELECT * FROM table_name WHERE column_name LIKE '%?%'

  • How to connect input string value to numerical values

    Hello,
    I am trying to figure out how to connect a single user's input string value to numerical values. Basically I want the user to input the name of a gas that I have a list for (I believe i put the list of gasses in an array>). Then I want to match 2 numerical values "a" and "b" depending on which gas name the user has put in. These "a" and "b" values will be automatically matched with the gas name from a list I put. For example the gas hydrogen has a value of 3 for "a" and 4 for "b. so when the user puts the name "hydrogen" in a string constant, automatically  "a" and "b" should be outputted. I will be connecting a and b to a formula
    Thanks for any help
    Solved!
    Go to Solution.

    student11 wrote:  These "a" and "b" values will be automatically matched with the gas name from a list I put. For example the gas hydrogen has a value of 3 for "a" and 4 for "b".
    This sounds a lot like an Enum to me.  Make sure you type def the enum to make sure updates quickly and easily make it to all copies of the enums.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Direct BW Query Connectivity Option in Xcelsius

    Hi Experts,
    I have just attended Tech Ed-2009 , and found that Xcelsius offer the direct connectivity to Bex Query.
    Which Xcelsius version offer this functionility ?
    I have Xcesius Enterprise - 2008 at Sp-2 level , however i don't see any direct connectivity option there.
    I have seen the interface in tech Ed and there is option of "SAP" on the top left where the file and edit and view appers.
    Please help me in finding that version ?
    Also is that version is available for trail download ?
    Thanks
    Ashwani

    Hi,
       Which Xcelsius version offer this functionility ?
       Xcelsius Engage 2008 SP2 only.
      Refer this blog, which is explain you, sopftware needed
    http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3417700)ID0762448650DB01786970309113616906End?blog=/pub/wlg/14966
    This for how to create dashboard using direct BI connection
    Connecting SAP BI Directly with Xcelsius 2008
    /people/rashmi.gurjar/blog/2009/11/18/connecting-sap-bi-directly-with-xcelsius-2008
    You can also download the trial version from this link
    http://www.sap.com/solutions/sapbusinessobjects/sme/freetrials/index.epx
    Regards,
    Senthil k

  • Hierarchical query - CONNECT BY and result in different columns.

    Hi everyone,
    I have a small question, hoping that someone can help me. As you will see, this
    is not very important. It's just me wondering if I can learn something in SQL.
    Let's suppose I have an ORGANIZATIONS table:
    CREATE TABLE ORGANIZATIONS (
      ID_ORGANISATION NUMBER(10) PRIMARY KEY,
      NAME VARCHAR2(255) NOT NULL,
      ID_PARENT_ORGANIZATION NUMBER(10)
    INSERT INTO ORGANIZATIONS(1, 'Parent of all', null);
    INSERT INTO ORGANIZATIONS(11, 'Child 11', 1);
    INSERT INTO ORGANIZATIONS(111, 'Child 111', 11);
    INSERT INTO ORGANIZATIONS(112, 'Child 112', 12);
    INSERT INTO ORGANIZATIONS(12, 'Child 12', 1);
    INSERT INTO ORGANIZATIONS(121, 'Child 121', 12);Let's also assume that we can have an undefined number of levels.
    Now, my question:
    With a query like
    SELECT LPAD(' ', LEVEL) || NAME  as conc
      FROM ORGANIZATIONS
    START WITH ID_ORGANIZATION = 1
    CONNECT BY PRIOR ID_ORGANISATION = ID_PARENT_ORGANIZATION
    ..I have a result like
    [conc]
    "Parent of all"
       "Child 11"
         "Child 111"
         "Child 112"
       "Child 12"
       ...All in one columns.
    What I'd like is a result like this one:
    [LEVEL_1]         [LEVEL_2]      [LEVEL_3]
    "Parent of all"
                      "Child 11"
                                     "Child 111"
                                     "Child 112"
                      "Child 12"
                                     "Child 121"I'd like to have this structure for the 5 first levels. Do you think this is possible or not?
    Thanks for your advice,

    user13117585 wrote:
    I'd like to have this structure for the 5 first levels. Do you think this is possible or not?Yes, something like...
    SQL> ed
    Wrote file afiedt.buf
      1  SELECT DECODE(LEVEL,1,NAME) as conc1
      2        ,DECODE(LEVEL,2,NAME) as conc2
      3        ,DECODE(LEVEL,3,NAME) as conc3
      4        ,DECODE(LEVEL,4,NAME) as conc4
      5        ,DECODE(LEVEL,5,NAME) as conc5
      6        ,DECODE(LEVEL,6,NAME) as conc6
      7  FROM ORGANIZATIONS
      8  START WITH ID_ORGANISATION = 1
      9* CONNECT BY PRIOR ID_ORGANISATION = ID_PARENT_ORGANIZATION
    SQL> /
    CONC1                CONC2                CONC3                CONC4                CONC5             CONC6
    Parent of all
                         Child 11
                                              Child 111
                         Child 12
                                              Child 112
                                              Child 121
    6 rows selected.
    SQL>Just add levels as you need them.

  • Query for CSV string construction

    Empid                         Ename
    1                                                                a
    1                                          b
    2                                          C
    2                                       d
    3                                           e
    I want  output like        empid                  Ename
    1                                                  (a,b)
    2                                                  (c,d)
    3                                                  e               How
    can u solve this

    Check the following blog on comma delimited string creation:
    http://www.sqlusa.com/bestpractices/training/scripts/commadelimitedlist/
    See example 4
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Design & Programming
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • Hierarchical Query - Connect By clause

    Hi
    I've written a query using the Connect By clause to generate the table data in Tree structure with the appropriate levels.
    But Data might not correct such that it may have data which loops around. Like Table1 is parent of Table 2 and Table 2 is parent of Table 3 and Table 3 is again Parent of Table 1. If such incorrect Data exists then I'm getting Oracle Error "ORA-01436: CONNECT BY loop in user data" which is correct.
    What I need is, whenever this error message is raised I need to give my own error message instead of this Oracle error in SQL statement. Please note, I'm not using any PLSQL block, I just have one SQL statement. Appreciate any help on this subject. Thanks.

    Hi,
    Outside of PL/SQL, I don't know of any way to substitute your own error messages for the ones Oracle provides.
    In Oracle 10 (and up), you can write a query using the CONNECT_BY_ISCYCLE pseudo-column. Using CONNECT BY NOCYCLE, the query will never actually raise the ORA-01436 error, but you can get it to display your message in cases where it would have, had you not been using CONNECT BY NOCYCLE.
    Here's how to do it:
    Put your real query, plus CONNECT_BY_ISCYCLE, in the WITH-clause.
    Get the MAX (CONNECT_BY_ISCYCLE) from that sub-query. Let's call this max_cbi.
    Do a UNION ALL of two prongs:
    (1) SELECTs everything (except, pehaps, CONNECT_BY_ISCYCLE) from the sub-query, WHERE max_cbi = 0
    (2) SELECTs your "error message" from dual, WHERE max_cbi = 1.
    Edited by: Frank Kulash on Nov 26, 2008 2:09 PM

  • BI Query Connection Error

    Hi,
    I am using BI Query Data source in my model. When deploy and test it, I am getting this error.
    Connection Error.
    Please contact your System Administrator.
    Details:
    HTTP request error
    In Portal System landscape. I have done the connection test and its working properly. I have also checked the Allow External Access Check Box in BI Query.
    Pl. Throw some light.
    Thanks,
    Mathivanan

    I solved this one. It was because, I forgot mention system type as BW in Portal Landscape. Now this is working fine.

  • ADF query panel searching string characters

    I have a field in the database as clientid which is of the type varchar2. This field is exposed as a field in the query panel in the front end.
    The problem is that the client wants the search option "between" (found in the advanced option of the query pane) to work like a number.
    That is if the client searches for a value between 5 and 7 , it should not return values such as 51,52,5232 etc . (which is actually the correct behaviour for varchar fields)
    But the client does not want the field to be changed to number instead of varchar2 (since he wants to enter alphabet characters in the future as well).
    So is there a way to make the search functionality to work like numbers instead of characters for the field clientid.
    J dev version Studio Edition Version 11.1.1.4.0

    Hi,
    just a guess, but maybe worth trying a custom domain for the attribute. If you can "translate" String to Number and Number to String on the fly then the filter should work fine
    http://www.baigzeeshan.com/2011/07/working-with-domain-type-in-adf.html
    Frank

Maybe you are looking for

  • Syncing issues with ipad ios5

    I have updated to the new os - when syncing - itunes is stuck on step 7 of 7 - downloading safari - is it a bug in the new version? Is there a solution?

  • Adding 0's before a number

    Hi all,       I have a text field where if i enter 008 its reading as 8, but I want to read it as what ever number I enter in InfoPath form.I tried with number field didn't work. Any suggestions please. Thanks,

  • My skype no shows Line Busy Always

    Hello, I have got Skype No for US [number redacted for privacy] forwarded to my Indian mobile no. However, if someone calls this no it always shows "Line Busy". Ideally, it should forward calls to my Indian mobile and also offer Voice Msg options..

  • Me21n workflow and bte

    Hi all, I'm trying to set a workflow to be generate when i create a new PO. (With tcode ME21N) I tried to put a workflow on BUS2012 (which i think is the correct one for this transaction): BUS2012     RELEASED     WS90000004 BUS2012     RELEASESTEPCR

  • Creating Folder for Existing Folders

    Is it possible to create a new folder for AR for iOS so that you can move already existing folders into it? My folders have become a bit cluttered as I had to create more for specific files, but they should all be filed under another bigger folder. T