How to return one ROW with Multiple value seperated by Colon in a SQL Query

Hi,
I have a SQL query as mentioned.
select deptno
  from deptI want to mofidfy this query, so that this should return me department list with colon delimeted in one ROW.
10:20:30:40.......Thanks,
Deepak

In 10g:
select rtrim(xmlagg(xmlparse(content deptno || ':')).getstringval(), ':') data
from   dept;
DATA                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
10:20:30:40with apologies for the abuse of XML...

Similar Messages

  • How to return all rows with duplicate values? Inner join not working!

    I have a 3 column table:
    location (pk), name, size
    I am attempting to select pairs of entries that have the same
    name and size but different values for location (it is the
    primary key.) My inner join does not seem to return what I need:
    select a.location, a.name, a.size, b.location, b.name, b.size
    from mytable a, mytable b where a.name = b.name and a.size =
    b.size and a.location <> b.location;

    One solution is like this:
    SELECT dname, loc, deptno
    FROM dept
    WHERE (dname, loc) IN
    (SELECT dname, loc
    FROM dept
    GROUP BY dname, loc
    HAVING COUNT (*) > 1
    ORDER BY dname, loc, deptno
    Regards
    Zlatko Sirotic

  • How just return one row of a one to many join..

    So I have a one to many join where the SMOPERATOR table has data I need however it has a couple of rows that match the JOIN condition in there. I just need to return one row. I think this can be accomplished with a subquery in the join however have not been able to come up with the right syntax to do so.
    So:
    SELECT "NUMBER" as danumber,
    NAME,
    SMINCREQ.ASSIGNMENT,
    SMOPERATOR.PRIMARY_ASSIGNMENT_GROUP,
    SMOPERATOR.WDMANAGERNAME,
    SMINCREQ.owner_manager_name,
    SMINCREQ.subcategory, TO_DATE('01-'||TO_CHAR(open_time,'MM-YYYY'),'DD-MM-YYYY')MONTHSORT,
    (CASE WHEN bc_request='f' THEN 'IAIO'
    WHEN (bc_request='t' and substr(assignment,1,3)<>'MTS') THEN 'RARO'
    WHEN (bc_request='t' and substr(assignment,1,3)='MTS') THEN 'M'
    ELSE 'U' end) as type
    from SMINCREQ
    left outer join SMOPERATOR on SMINCREQ.assignment=SMOPERATOR.primary_assignment_group
    WHERE SMINCREQ.owner_manager_name=:P170_SELECTION and SMOPERATOR.wdmanagername=:P170_SELECTION
    AND open_time BETWEEN to_date(:P170_SDATEB,'DD-MON-YYYY') AND to_date(:P170_EDATEB,'DD-MON-YYYY')
    AND
    (bc_request='f' and subcategory='ACTIVATION' and related_record<>'t')
    OR
    (bc_request='f' and subcategory<>'ACTIVATION')
    OR
    (bc_request='t' and substr(assignment,1,3)<>'MTS')
    order by OPEN_TIMe

    Hi,
    This sounds like a Top-N Query , where you pick N items (N=1 in this case) off the top of an orderded list. I think you want a separate ordered list for each assignment; the analytic ROW_NUMBER function does that easily.
    Since you didn't post CREATE TABLE and INSERT statements for your sample data, I'll use tables from the scott schema to show how this is done.
    Say you have a query like this:
    SELECT       d.dname
    ,       e.empno, e.ename, e.job, e.sal
    FROM       scott.dept  d
    JOIN       scott.emp   e  ON   d.deptno = e.deptno
    ORDER BY  dname
    ;which produces this output:
    DNAME               EMPNO ENAME      JOB              SAL
    ACCOUNTING           7934 MILLER     CLERK           1300
    ACCOUNTING           7839 KING       PRESIDENT       5000
    ACCOUNTING           7782 CLARK      MANAGER         2450
    RESEARCH             7876 ADAMS      CLERK           1100
    RESEARCH             7902 FORD       ANALYST         3000
    RESEARCH             7566 JONES      MANAGER         2975
    RESEARCH             7369 SMITH      CLERK            800
    RESEARCH             7788 SCOTT      ANALYST         3000
    SALES                7521 WARD       SALESMAN        1250
    SALES                7844 TURNER     SALESMAN        1500
    SALES                7499 ALLEN      SALESMAN        1600
    SALES                7900 JAMES      CLERK            950
    SALES                7698 BLAKE      MANAGER         2850
    SALES                7654 MARTIN     SALESMAN        1250Now say you want to change the query so that it only returns one row per department, like this:
    DNAME               EMPNO ENAME      JOB              SAL
    ACCOUNTING           7782 CLARK      MANAGER         2450
    RESEARCH             7876 ADAMS      CLERK           1100
    SALES                7499 ALLEN      SALESMAN        1600where the empno, ename, job and sal columns on each row of output are all taken from the same row of scott.emp, though it doesn't really matter which row that is.
    One way to do it is to use the analytic ROW_NUMBER function to assign a sequence of unique numbers (1, 2, 3, ...) to all the rows in each department. Since each sequence startw with 1, and the numbers are unique within a department, there will be exactly one row per departement that was assigned the numebr 1, and we''ll display that row.
    Here's how to code that:
    WITH     got_r_num     AS
         SELECT     d.dname
         ,     e.empno, e.ename, e.job, e.sal
         ,     ROW_NUMBER () OVER ( PARTITION BY  d.dname
                                   ORDER BY          e.ename
                           )         AS r_num
         FROM     scott.dept  d
         JOIN     scott.emp   e  ON   d.deptno = e.deptno
    SELECT       dname
    ,       empno, ename, job, sal
    FROM       got_r_num
    WHERE       r_num     = 1
    ORDER BY  dname
    ;Notice that he sub-query got_r_num is almost the same as the original query; only it has one additional column, r_num, in the SELECT clause, and the sub-qeury does not have an ORDER BY clause. (Sub-queries almost never have an ORDER BY clause.)
    The ROW_NUMBER function must have an ORDER BY clause. In this example, I used "ORDER BY ename", meaning that, within each department, the row with the first ename (in sort order) will get r_num=1. You can use any column, or expression, or expressions in the ORDER BY clause. You muight as well use something consistent and predictable, like ename, but if you really wanted arbitrary numbering you could use a constant in the analytic ORDER BY clause, e.g. "ORDER BY NULL".

  • Returning 250 rows with 1000 Values in "IN" Clause Oracle 10g On IBM AIX !!

    Hi,
    Recently we have done the OS migration of Oracle 10g Server from Windows Server to IBM AIX. Everything is fine, But today we came across one crucial bug in the code, i.e In the Select Query, though we're expecting 1000 rows with 1000 values in "IN" Clause , It's returning Only 250 rows. Where as it's returning 1000 rows in Windows Environment with 1000 values in "IN" Clause. I have browsed throgh Google for the resolution but failed to get that.
    This is something like,
    In Oracle 10g On windows :-
    select * from emp
    where dept_id in (1,2,3,...................1000);
    Assuming there  are the dept_id values in Emp table from 1 ... 1000, It's returning 1000 rows.
    In Oracle 10g On IBM AIX ,
    select * from emp
    where dept_id in (1,2,3,...................1000);
    Assuming there  are the dept_id values in Emp table from 1 ... 1000, It's returning 250 rows. Pls help me, what could be the reason for this. and what needs to be checked to fix this.
    Pls suggest !!!
    Raja

    mmmh. Did you compared the select count(*) from your_table; in the two cases.
    If the result is not good and nobody has deleted rows between migration and your test, you migration need to be replayed.
    Which migration did you select, Transportable database or exp/imp...?
    Edited by: Dba Z on 16 août 2009 08:56

  • How to have one provider with multiple portlets in JDev 11g

    Hi,
    I am trying to create Oracle PDK Portlets using JDeveloper 11g but for each portlet JDeveloper is creating a provider. As In JDeveloper 10.1.3.4 we can have one provider with multiple portlets in it. But JDev 11g creates provider for each portlet. How can we have one provider with multiple portlets in JDev 11g. Is it something changed in 11g version or am I doing it wrong. As the Help says we can have multiple portlets in one provider but when creating portlets it does not do that. Any help is appreciated.
    Thanks

    Hi,
    I am trying to create Oracle PDK Portlets using JDeveloper 11g but for each portlet JDeveloper is creating a provider. As In JDeveloper 10.1.3.4 we can have one provider with multiple portlets in it. But JDev 11g creates provider for each portlet. How can we have one provider with multiple portlets in JDev 11g. Is it something changed in 11g version or am I doing it wrong. As the Help says we can have multiple portlets in one provider but when creating portlets it does not do that. Any help is appreciated.
    Thanks

  • How to use one PSE with multiple URLs?

    I need to hit my DMZ SAP Web Dispatcher with multiple unique URLs.  I am starting off using webdisp1.abc.com and webdisp2.vde.com.  DNS will resolve both the Web Dispatcher Host.  Following Tobias Winterhalter's Blog: Name-based virtual hosts and one SAP Web Dispatcher to access multiple SAP systems.
    My question is how do I go about generating the pse so I can store both webdisp1.abc.com and webdisp2.vde.com?  Do I just import the first request and initiate another certificate request using the same pse?
    Example
    sapgenpse gen_pse -s 2048 -p D:\<file path>\SAPSSLS.pse -r D:\<file path>\webdisp1.req CN=webdisp1.abc.com, OU=IT, O=XYZ Inc., C=US
    Cheers,
    Dan Mead

    Hi Daniel,
    what you are looking for are so called SAN certificates. As Martin said, with sapgenpse you are pretty out of luck. However you can create the certificates using openssl and then use sapgenpse to import them into a pse. There are a number of guides on how to create SAN certificates on the web, like the one mentioned by Martin from CAcert (which is one of the best imho) or this one. And there are also guides on the internet on how to convert OpenSSL keys to PSE.
    You should however keep in mind, that SAN certificates are more expensive than standard certificates. Therefor they only pay if the hostnames in there are stable for the lifetime of the certificate. If the hostnames need to change once a year, you already will be better off (from a cost perspective) by creating one pse per hostname an let the webdispatcher listen to different addresses, as each hostname requires a new certificate signed by the CA.
    Please also make sure, the systems and browsers connecting to your webservers are able to understand SAN certificates. For SAP systems this requires at least pl24 of the sapcryptolib.
    Kind regards,
    Patrick

  • How to control one server with multiple clients via TCP/IP

    I am wanting to control a single server with multiple clients.  Only one client would be active at a time, so there would be no conflict.  I want to use TCP/IP.  So far, I have programmed a cluster that passes data back to the server with no problems.  The challenge come in when a second client is added to the mix.  I have't been able to figure out how to turn each client on and send the appropriate data and then turn it off so it doesn't keep sending the same data to the server. 
    Here are the things that I have considered and did some preliminary testing, but don't really know how to impliment:
    1.  Send a numeric on the front of the cluster packet that tells the server that data is on the way.
    2.  Send a boolean on the front of the cluster packet to somehow turn the server TCP/IP on.
    The problem I have found is that LabVIEW TCP/IP doesn't like to be turned on and off.  If it doesn't get the data it expects, it goes into a reset mode and that kills the response time.
    Any help?

    You should consider implementing a set of simple one-byte commands that can be sent back and forth between the Server and the Clients. You can base all of these ideas off the example in the Example Finder under Networking >> TCP and UDP called Multiple Connections - Server.
    You will have two loops in the server VI: one to wait for new connections, and one to send and receive data from the existing connections. For instance, after one of the clients connects, it can request control of the server to send data to it by sending the character "R" for request. Every time the send/receive loop of the Server executes, the first thing it can do is to check all the existing connections to see if any of the clients have sent a control request ("R"). If so, it will create a buffer (array) of control requests. This could be in the form of Connection IDs or indexes in the array for a particular Connection ID. Your choice.
    After the Server receives a request for contol, if it is not already under control by another client, then it can send a response to the first client on the control request list. For instance, the server could send the first client a "S" command for send. Note that after the clients send their control request, they should execute a TCP Read and wait indefinitely for the server to respond with the one-byte "S" command. Then, once the client in control is finished sending data to the server, it could send the character "X" telling the Server to release it from control.
    The example I mentioned above already does a similar thing. Note how when a client wants to disconnect, they send the letter "Q". You can see this in the Multiple Connections - Client VI. The Server then checks each individual connection to see if it's received this one-byte command, and if it has, it closes the connection to the client. This is what you would want to implement, but instead of having just one command, you'll have to distinguish between a few and build up a buffer of control requests.
    Finally, if a client does decide to disconnect in your application, they could send the command "Q" just like the example above. At this point, close the connection and remove that Connection ID from the array of connections. You will also have to handle the case that this client was in the request control waiting line when it disconnected, in which case you need to delete it from that array as well.
    This will definitely work for you, but it will take some work. Best of luck!
    Jarrod S.
    National Instruments

  • How to Map one key to multiple values

    Hello Everyone
    Let's say I have a System. to access this system, one needs a username and a password. Now i have a Hashtable that maps passwords to their usernames. Now what if i want to store the Firstname and lastname of the person, in case he/she forgets the password or username? Is there a way to associate a key (Password) to multiple values(username, password, lastname)? if so, can you show me how to go about it?
    Edited by: Tonata on Apr 27, 2009 8:09 AM

    M.Murat wrote:
    Hello
    My suggestion is that you can create a map in which value is a list(for example Arraylist).
    You can store the items in that list and match that list to proper key.
    M.MuratCode smell: Object Denial+_                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Convert multiple rows to one row with multiple columns

    Hi
    i have a table Match_1 with 2 columns 'Source' and 'target'.One source can have multiple targets and that number could be anything
    CREATE TABLE Match_1
    Source CHAR(1),
    Target CHAR(1)
    INSERT INTO Match_1 VALUES ('A', 'B');
    INSERT INTO Match_1 VALUES ('A', 'C');
    INSERT INTO Match_1 VALUES ('A', 'D');
    INSERT INTO Match_1 VALUES ('A', 'E');
    INSERT INTO Match_1 VALUES ('V', 'X');
    INSERT INTO Match_1 VALUES ('V', 'Y');
    INSERT INTO Match_1 VALUES ('V', 'X');
    INSERT INTO Match_1 VALUES ('V', 'W');
    COMMIT;
    i need to get my output in the below format
    Source     target 1     target 2     target 3     target 4          target n
    A     B          C          D               
    V     X          Y          Z          W          
    Could you please provide me the required SQL.
    REgards
    -Learnsequel

    What is your database version (4 digit) ? also my example won't be generate columns for your information:
    it will produce a result like that :
    select source, listagg(target,',') within group (order by target)
      from  match_1
      group by source;
    A     B,C,D,E
    V     W,X,X,Yps: in previos post, I wrote "with" word wrong in sql.

  • How to make input parameter with multiple values in function module?

    Dear Experts,
    I want to add BUKRS as import field to a FM, what is the best way of of making it accept multiple enteries.
    Regards,
    Kiran

    hI kiran,
    The simple way is to create a data element & domain with value range where u provide set of fixed values or provide a check table to it.
    Use that data element in a table <ztable>.
    Code:
    Parameters:
          p_burks like <ztable>-dataelement.
    Call Function <function_name>
    exporting
    p_burks = p_burks,

  • How to transform one row to multiple row

    I have excel data of form
    Name
    Roll No.
    Prakash
    28,32
    Jitendra
    38,45
    Satendra
    43,73
    I want to transform it to this form and insert it to sql database
    Name
    Roll No.
    Prakash
    28
    Prakash
    32
    Jitendra
    38
    Jitendra
    45
    Satendra
    43
    Satendra
    73
     How to do it.
    prakash kumar jha

    It can be  done with "Script Component" transformation by making it as asynchronous component ((because
    the number of output rows differs from the number of input row) .
    To make the component as asynchronous ,we need to  set the "SynchronousInputId" property to None
     In an asynchronous script component you have to override the "Input0_ProcessInputRow"
    method.
    Example:
    Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
        Dim keyField As Integer = Row.KeyField 
        Dim itemList As String = Row.ListField 
        Dim delimiter As String = ","
        If Not (String.IsNullOrEmpty(itemList)) Then
            Dim inputListArray() As String = _ 
                itemList.Split(New String() {delimiter}, _ 
                StringSplitOptions.RemoveEmptyEntries)
            For Each item As String In inputListArray 
                With Output0Buffer 
                    .AddRow() 
                    .KeyField = keyField 
                    .ListItem = item 
                End With 
            Next
        End If
    End Sub 

  • How to use one application with multiple schema without copying application?

    Hi,
    Previously we are using oracle forms and by that we can manage by using a set of folders containing fmx and use different schema/database for different customers. so the source code comes from one individual file but used for different database users.
    is it possible to do this without copying application in apex?
    reason is because if applications are copied for each customer, and in a situation where a page has a bug, the developer must correct multiple pages across all the application. This would not be appropriate to manage.
    could this be done in apex? or is there any other approach?

    Hi,
    An application is tied to its parsing schema, so it is not possible to have one code base which you can then point to different schemas. I have seen some threads relating to dynamically setting the parsing schema, but I don't think it has worked to well, and would not be a supported configuration by Oracle.
    The normal way to do this is to have one schema and for each entity where it is logical you will have an extra key which is the customer id. I mention where it is logical, because not every entity needs its own data defined by customer. Some data will be common across all customers, such as lookup data and some entities will comprise child entities by which the data separation will be implied by the parent. You can then use Oracle's Virtual Private Database feature to implement a seperate view of the data through the application, based most likely on the customer who is logged on.
    Hope this helps.
    Regards
    Andre

  • How to select one row with such sql

    hi , everyone
    I got a headache about this sql:
    select * from E_VPN_pbxlink where ((SPILOTNUM ='1234' ) or (SPILOTNUM ='123')) order by SPILOTNUM desc ;
    it retruns 2 records.
    I need to get the record with SPILOTNUM ='1234' , how can I reform this sql
    tks

    Hi,
    I think I see:
    You want the longest spilotnum that starts with the same charachters as the parameter.
    You can do a Top-N Query like this:
    WITH  got_rnum     AS
         select  e.*
         ,     RANK () OVER (ORDER BY  LENGTH (spilotnum DESC)     AS rnum
         from      E_VPN_pbxlink
         where      '123456'     LIKE SPILOTNUM || '%'
    SELECT     *     -- or list all columns except rnum
    FROM     got_rnum
    WHERE     rnum     = 1
    ;There is a slightly simplerr way, using the ROWNUM pseudo-column, but its only slightly easier, and it won't help if, say, you want to pass two or more targets such as '123456' in the same query.

  • Deleting  rows with missing values in field in start routine of update rule

    Hello experts,
    how can I delet rows with missing values in a specific field in the start routine of update rules?
    I think ABAP code should look something like this:
    delete ...  from DATA_PACKAGE where Z_NO = ''.
    thanks in advance for any suggestions!
    hiza

    Write:
    delete data_package where field = value.
    Hope it helps.
    Regards

  • [ASK] Get One Row of Property Value From Dimension in Script Logic

    Hello, i need help about how to get one row of property value from dimension in script logic.
    Let say there is CATEGORY dimension and the members are like this :
    ID                                                  YEAR   Status
    PLAN_2011                                   2011        A
    PLAN_2011_V1                            2011        I
    ACTUAL_2011                              2011        I
    FORECAST_2011                         2011        I
    FORECAST_2011_V1                  2011        A
    PLAN_2012                                  2012        A
    PLAN_2012_V1                           2012        I
    ACTUAL_2012                             2012        I
    FORECAST_2012                         2012        I
    FORECAST_2012_V1                  2012        A
    If i scope CATEGORY like this :
    *XDIM_MEMBERSET CATEGORY = [CATEGORY].PROPERTIES("YEAR") = "2011"
    Then i will get member scope like this :
    PLAN_2011                                   2011        A
    PLAN_2011_V1                            2011        I
    ACTUAL_2011                              2011        I
    FORECAST_2011                         2011        I
    FORECAST_2011_V1                  2011        A
    Question :
    In script logic, how can i read the second record of scope and move it to variable ?
    Ex. : I read second record, so i can get the data of second record (PLAN_2011_V1, 2011, A).
    Is there any function to read all record that had been scope ? So i can read all those 5 records.
    Is there any substring or offset function in script logic ? How to use it ?
    Thank you.

    Hi,
    Firstly, when we scope the logic, it doesnt fetch the entire record from the member sheet. It just fetches the ID.
    Secondly, we dont have the feasibility to read only the second ID and skip the others. However, one alternative is that you use the SELECT statement to store all the IDs in a variable, and then use a FOR loop. But this will loop through all the 5 IDs, as per your example. If you want to skip all the IDs except one, you should maintain some property, so that all the IDs are neglected which doesnt have a particular property value.
    Hope you got the idea.

Maybe you are looking for

  • Installing Functional Module as a Customer Extension

    Hi All, Am not a Basis guy and have stuck up in a issue at customer place. I need to import, install and activate function module as transport into the R/3 system. In Note # 1050096, there is a attachment with two files K900947.SM0 R900947.SM0 I need

  • Where am I missing in calling this FM

    I calling a std FM in smartform and below is my logic: DATA: i_komv   TYPE STANDARD TABLE OF komv,       i_komvd  TYPE STANDARD TABLE OF komvd,       wa_komk  TYPE komk,       wa_komv  LIKE LINE OF i_komv,       wa_komvd LIKE LINE OF i_komvd. break d

  • I try to download adobe flash on my mac but every time it gets to a certain point and quits. Any suggestions?

    I have had a Mac in the past and had no problem with downloading adobe flash but for some reason my laptop will not let me get flash. What should I do?

  • Regarding Time Management Query

    ***Dear experts,*** ***The employee who is "present" marked as "absent" and the employee who is "absent" has got payment.*** ***Further leave combinations/Leave rules are not working properly.***

  • Compress mp3 file so that I can email.

    I recorded a speaker in an mp3 file.  The file is too large to email but I want to share by email with friend.  Any recommendation on how to compress the file so that I can email?  The file is approximately 29 mb.