How to select each character of column value

Hi All,
How can i get each character separately of a column value in a select statement.
LIKE i emp table if ename='Test' then i want
a select statement that can give me the result like this
T,e,s,t
Regards,
Anil R

or this?
SQL> create table mytable
  2  as
  3  select 'test' text from dual union all
  4  select 'a text, containing two comma''s (,)' from dual union all
  5  select 'a text ending with a comma,' from dual
  6  /
Tabel is aangemaakt.
SQL> select text
  2       , substr(regexp_replace(text,'(*?)',',\1'),2,length(text)*2-1) with_commas
  3    from mytable
  4  /
TEXT                               WITH_COMMAS
test                               t,e,s,t
a text, containing two comma's (,) a, ,t,e,x,t,,, ,c,o,n,t,a,i,n,i,n,g, ,t,w,o, ,c,o,m,m,a,',s, ,(,,,)
a text ending with a comma,        a, ,t,e,x,t, ,e,n,d,i,n,g, ,w,i,t,h, ,a, ,c,o,m,m,a,,
3 rijen zijn geselecteerd.Regards,
Rob.
Message was edited by:
Rob van Wijk
Slight modification to cater for strings beginning and ending with commas.

Similar Messages

  • How to select 2column from 1 column values

    Hi All,
    How to select 2column from 1 column values
    Ex : In Emp they have JOB column
    JOB
    CLERK
    MANAGER
    SALESMAN
    MANAGER
    MANAGER
    ANALYST
    PRESIDENT
    SALESMAN
    CLERK
    CLERK
    ANALYST
    CLERK
    here i want to get output like as follows
    Ex: ejob1 ejob2
    ANALYST SALESMAN
    ANALYST SALESMAN
    Can anyone helps me in this,it is urget
    Thanks,

    Something like
    select a.job, b.job from scott.emp a, (select job from scott.emp) b
    CLERK     CLERK
    CLERK     SALESMAN
    CLERK     SALESMAN
    CLERK     MANAGER
    CLERK     SALESMAN
    CLERK     MANAGER
    CLERK     MANAGER
    CLERK     ANALYST
    CLERK     PRESIDENT
    CLERK     SALESMAN
    CLERK     CLERK
    CLERK     CLERK
    CLERK     ANALYST
    CLERK     CLERK
    SALESMAN     CLERK
    SALESMAN     SALESMAN
    SALESMAN     SALESMAN
    SALESMAN     MANAGER
    ...

  • How to select  rows with duplicate column values

    hi,
    i have a table property_details which has these 2 columns customerno and propertyno a customer can have many properties and property number has to be unique. but somehow these property number has been duplicated at an earlier stage so i have for a customer with many properties the same property number
    how i will select such records whose asset numbers are the same
    for ex
    customer no property no
    a1300 1
    a1300 1
    a1300 1
    a2330 10
    a2330 10
    a2330 10
    kindly suggest me a solution

    this example might be of help.
    SQL> select * from employees;
    YEAR EM NAME       PO
    2001 02 Scott      91
    2001 02 Scott      01
    2001 02 Scott      07
    2001 03 Tom        81
    2001 03 Tom        84
    2001 03 Tom        87
    6 rows selected.
    SQL> select year, empcode, name, position,
      2         row_number() over (partition by year, empcode, name
      3                            order by year, empcode, name, position) as rn
      4    from employees;
    YEAR EM NAME       PO         RN
    2001 02 Scott      01          1
    2001 02 Scott      07          2
    2001 02 Scott      91          3
    2001 03 Tom        81          1
    2001 03 Tom        84          2
    2001 03 Tom        87          3
    6 rows selected.
    SQL> Select year, empcode, name, position
      2    From (Select year, empcode, name, position,
      3                 row_number() over (partition by year, empcode, name
      4                                    order by year, empcode, name, position) as rn
      5            From employees) emp
      6   Where rn = 1;
    YEAR EM NAME       PO
    2001 02 Scott      01
    2001 03 Tom        81
    SQL>

  • OBIEE - How to selectively hide or disable columns on a dashboard prompt?

    Hello! I need some help with OBIEE dashboard Prompts. Any help will be highly appreciated!
    Question 1. How to selectively hide or disable columns on a dashboard prompt or the entire prompt? There seems to be no "hide" or "dsable" options on
    prompts.
    Question 2. How to synchronize 2 different prompts on the same dashboard?
    The application is this: There are total of 2 tabs on a dashboard ("tab_1" and "tab_2"). Each tab uses different prompts ("pr_1" and "pr_2"), having just one first drop down column in common ("Product_id").
    The desired functionality is this: user selects "Product_id" on the first tab's prompt, which filters its reports (on "Go") and also propagates to the second tab. When user clicks on the second tab, the reports there are already filtered (or begin filtering) by "product_id", selected on the first tab.
    Question 3. How to prevent the reports from retrieving when switching to a different tab on a dshboard? Specifying dummy default values in the prompt does
    not seem to preven reports from retrieving, which still takes time.
    Thank you very much!
    Roger

    Regarding Question 2:
    What you need to have is a Dashboard scope dashboard prompt for Product_ID (i.e., Don't use the column prompt from the prompt tab within the Request.)
    1) Create the dashboard prompt, put it on tab1 and save the prompt to a presentation variable, say prmtProdID. Set the scope to "dashboard." (This is the default, by the way.) If you create a dashboard prompt and set the scope to "dashboard," then the prompt values selected will hold true across dashboard pages.
    2) On tab2, go to your report and in Criteria mode, apply a filter to the Product_ID column making it equal to the PV. (Click the filter icon, Add>Variable>Presentation Variable and type prmtProdID. Save.)
    When the user selects a Product_ID on tab1 of your dashboard and hits "Go," not only will it filter your report on tab1, when you go to tab2 the report here will be filtered with the same value selected in the prompt on tab2.
    Regarding Question 3:
    If you implement 2, you cannot implement 3. You can't have it both ways. Not for the same scenario. But if you want to know how to do it in general, read this:
    http://obieeone.com/2009/08/24/how-to-stop-queries-to-automatically-fire-off-once-entering-dashboarddashboard-page/

  • How to update zero to a column value when record does not exist in table but should display the column value when it exists in table?

    Hello Everyone,
    How to update zero to a column value when record does not exist in table  but should display the column value when it exists in table
    Regards
    Regards Gautam S

    As per my understanding...
    You Would like to see this 
    Code:
    SELECT COALESCE(Salary,0) from Employee;
    Regards
    Shivaprasad S
    Please mark as answer if helpful
    Shiv

  • How to Select each check box values in a group of records

    Hi,
    I have a requirement in forms 10g. In that form there are 10 records are displaying each record has one check box is there if i click the check box on record number one and record number three and do some changes in the text field(adjustment field is number data type) then finally I want to see the total on one field called total amount.
    In this my question is how to select particular records in a group of records? and finally these selected records are inserted into one table.
    Because I am not able to fetch these records at a time.
    Is there any Array to define a record group to fetch each of them individually for example Rec[1],Rec[2]...like that if yes please suggest me the steps how to do this.
    Thanks in advance
    Prasanna
    Edited by: user10315107 on Dec 17, 2008 11:44 PM

    I'm sorry, but i didn't get your requirement in detail.
    Do you want to do the summing of the selected records in forms ? Or do you just want to know which records are selected and then process them?
    If you want to process the selected records in sql you could use an object-type to store the list of id's (of whatever primary key you use), loop over the block to fill it, and then afterwards process them.
    For this approach, first create an object-type in the database:
    CREATE OR REPLACE TYPE ID_LIST AS TABLE OF NUMBER;
    /Then, in forms you could do something like this to fill a list of id's:
    DECLARE
      lIds ID_LIST:=ID_LIST();
    BEGIN
      GO_BLOCK('MYBLOCK');
      FIRST_RECORD;
      LOOP
        EXIT WHEN :SYSTEM.RECORD_STATUS='NEW';
        IF :BLOCK.CHECKBOXITEM="CHECKEDVALUE" THEN
          lIds.EXTEND(1);
          lIds(lIds.COUNT):=:BLOCK.PRIMARYKEYITEM;
        END IF;
        EXIT WHEN :SYSTEM.LAST_RECORD='TRUE';
        NEXT_RECORD;
      END LOOP;
      -- Now you can use the object-list in SQL like :
      INSERT INTO MYNEWTABLE (cols..)
      SELECT (cols..)
        FROM MYOLDTABLE
       WHERE ID IN (SELECT COLUMN_VALUE FROM TABLE(lIds));
    END;Edited by: Andreas Weiden on 18.12.2008 18:17

  • How to select only rows which column has a null value?

    Hi,
    I adds rows to my table with data field set to null;
    "INSERT INTO administrator.subzamowienia (subzamowienia.id_zamowienia,subzamowienia.id_transakcji,subzamowienia.nazwa_o,subzamowienia.nazwa_produktu,subzamowienia.ilosc,subzamowienia.nip_d,subzamowienia.data_realizacji) VALUES (administrator.id_zamowienia.curval,'0','PRAGA','Witaminy','2','43224','0');"
    Then i would like to update this field after a time with new date.
    To do this i need to know which rows has still data field set to null, i try sth like this but it doesn't work
    "SQL> select * from administrator.subzamowienia where subzamowienia.data_realizacji='null';
    select * from administrator.subzamowienia where subzamowienia.data_realizacji='null'
    BŁĄD w linii 1:
    ORA-01841: (pełny) rok musi być pomiędzy -4713 i +9999 i nie może być 0
    or
    "SQL> select * from administrator.subzamowienia where subzamowienia.data_realizacji='0';
    select * from administrator.subzamowienia where subzamowienia.data_realizacji='0'
    BŁĄD w linii 1:
    ORA-01840: wartość wejściowa jest za krótka dla formatu daty
    how to choose this rows?

    Hi,
    VALUES (administrator.id_zamowienia.curval,'0','PRAGA','Witaminy','2','43224','0');I don't see null value...
    select * from administrator.subzamowienia where subzamowienia.data_realizacji='null'Should be :
    select * from administrator.subzamowienia where subzamowienia.data_realizacji is nullNicolas.

  • How to accessing current row report column value in Lov Query?

    Hi,
    which access methods (eg. bind variables, substitutions, ...) for getting the current row report column value can be used in the "Lov Query" property of a report column?
    As what I know of and what I have read on the forum there are no bind variables for the report columns. For the "Link Text" property it seems that the column values exist as substitution strings (#COLUMN_NAME#). But they don't work in the Lov Query. => And would be good because of a hard parse each time the Lov query is executed.
    The following post (Re: Simulating a correlated sub query in lov
    is showing a solution to use package variables for temporary storage of the referenced value, but the only problem with that solution is that if a new record is added with the "Add rows to tabular form" process the package variable still contains the value from the last queried row! Is there a way (variable, APEX package, ...) to determine if the lov query is executed for a new record so that the package can return null?
    I know that I could write the package in a way that the value is immediately cleared when lov_pkg.keyval is called (one time read), but then I would have to create several variables if I'm accessing the value multiple times in the query or in another query => I think an one time read solution would be very obscurely.
    Thanks for your help
    Patrick
    http://inside-apex.blogspot.com

    Hi Patrick,
    I agree that it's a waste to continually use Ajax to go back to the server to get the contents of a dynamic select list.
    There are no bind variables for any row item - but what you do have, as per my previous post, is the value of the data entered by the user in the first row. You can pass this into your application process (using get.add("VARIABLENAME", value)), which can use it to retrieve the correct LOV in your Ajax code - this will give you a "bind variable" that your process can use.
    What you could do, however, is generate hidden select lists on your page - one for each possible LOV list and replace the contents of the new row's select list with the contents of the appropriate hidden select list. This is easy to do with javascript (using innerHTML functions). Obviously, though, the usefulness of this depends on the number and size of the select lists.
    Even if you don't generate them to start with, you can keep a copy of any select lists returned by Ajax in the DOM for use on new rows. So, if you have retrieved a select list, you will have a copy of it in DOM which you can then copy into the new row. If you don't have the list in DOM, use Ajax to get it, store a copy of it and copy it into the new row.
    Which method you use will depend on the number/size of select lists needed. If they are few in number and/or size, I would suggest generating hidden lists. If they are large, use Ajax to get them once, store them and then retrieve them from the DOM when needed.
    There is another thread here where Arie recommends going to the server every time to make sure you get the most up-to-date data for the lists. If you want to follow this advice, for this reason, use get.add("VARIABLENAME", value) to pass the value to your process. If this is not an issue, you can use one of the other methods I outlined above.
    Regards
    Andy

  • How to Select data using same column name from 3 remote database

    Hi,
    Can anyone help me on how to get data with same column names from 3 remote database and a single alias.
    Ex.
    SELECT *
    a.name, b.status, SUM(b.qty) qantity, MAX(b.date) date_as_of
    FROM
    *((table1@remotedatabase1, table1@remotedatabase2, table1@remotedatabase3)a,*
    *(table1@remotedatabase1, table1@remotedatabase2, table1@remotedatabase3)b)*
    WHERE b.dept = 'finance'
    AND a.position = 'admin'
    AND a.latest = 'Y' AND (b.status <> 'TRM') AND b.qty > 0;
    GROUP BY a.name, b.status ;
    NOTE: the bold statements is just an example of what I want to do but I always gets an error beacause of ambiguous columns.
    Thanks in advnce. :)
    Edited by: user12994685 on Jan 4, 2011 9:42 PM

    user12994685 wrote:
    Can anyone help me on how to get data with same column names from 3 remote database and a single alias.Invalid. This does not make sense and breaks all scope resolution rules. And whether this is in a single database, or uses tables across databases, is irrelevant.
    Each object must be uniquely identified. So you cannot do this:
    select * from (table1@remotedatabase1, table1@remotedatabase2, table1@remotedatabase3) a3 objects cannot share the same alias. Example:
    SQL> select * from (dual, dual) d;
    select * from (dual, dual) d
    ERROR at line 1:
    ORA-00907: missing right parenthesisYou need to combine the objects - using a join or union or similar. So it will need to be done as follows:
    SQL> select * from (select * from dual d1, dual d2) d;
    select * from (select * from dual d1, dual d2) d
    ERROR at line 1:
    ORA-00918: column ambiguously definedHowever, we need to have unique column names in a SQL projection - so the join of the tables need to project a unique set of columns. Thus:
    SQL> select * from (select d1.dummy as dummy1, d2.dummy as dummy2 from dual d1, dual d2) d;
    DUM DUM
    X   X
    SQL> I suggest that you look closely at what scope is and how it applies in the SQL language - and ignore whether the objects referenced are local or remote as it has no impact to fundamentals of scope resolution.

  • How to add spaces to the column value to make it up specifi length string please

    Hello There,
    Could you please guide me here to solve this issue,
    in my column (named as State) contains values as below
    California
    Washington
    Utah
    Connecticut
    Massachusets
    in the output how can i add a spaces to make up every column values as 15 length (for ex, Utah is 4 length then need to add 11 spaces, California is 10 would like to add 5 spaces)
    i tried below but no use in Sql 2008 R2
    SELECT  distinct state
       state
    +SPACE(35-len(state)),
    len(state+SPACE(35-len(state)))
    FROM dbo.ordersInfo
    Thank you in advance
    Milan

    Fixed length CHAR(n) data in SQL is automatically padded with spaces. Either change the column's data type or cast to it. Also, the ISO-11179 rules are that the column should be "state_name" and not just the root attribute "state" -- state_code, state_population,
    etc are a few of the confusions you created. 
    Another rule of RDBMS is that we do not do display formatting in the data. That is what presentation layers do. Why are you trying to fake COBOL in SQL? 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • How  to identfy  rows  with  same  column value

    Hi
    I have a table student
    id ( pkey)
    name
    class
    marks
    i need to check the existence of duplicate values like
    say the values are :
    id name class marks
    1 alan 6 85
    2 victor 4 97
    3 alan 6 85
    i need to know if there is any matching row in the table --- like in this case id=1 and id=3 have same value for all the columns except for id .
    so the result shud tell me the ids which have duplicate values for name , class , marks and also those ids for which there is no duplicacy
    for id= 1 i see that id= 3 has same values
    and id=2 has no duplicates
    how do i show it ??
    The result i expect is
    name class marks count
    alan 6 85 2
    victor 4 97 1
    Message was edited by:
    SHUBH

    EMP
    id name class marks
    1 alan 6 85
    2 victor 4 97
    3 alan 6 85
    You can use a self join to pull out the data which are almost duplicate without a column values here in this example without id the first and third records are duplicate.
    select e.id,e.name,e.class,e.marks from EMP e,EMP d where e.name=d.ename and e.class=d.class and e.marks=d.marks and e.id<>d.id;

  • How to get each character in a string

    as in 'C' we use arrays to get each character of a string stored in array.how can we get each character of a string stored in a variable.

    Hi,
    For that you need to do offset.
    for example one variable called VAR contains string 'HUMERAH'.
    if you want each character of that string then you need to decalre as many variable as the number of string.
    like
    data : var1(1),
             var2(1),
    var(3),
    var(4).
    var1 = var+(1).
    var2 = var+1(1).
    var3 = var+2(1).
    var4 = var+3(1).
    now var1,var2,var3,var4. contains the single characters.
    Regards,
    Guru
    mark helpful answers

  • How to get the Row and Column values in ALV (without using Objects)

    Hi All,
    I need to get the Row / Column when double click is used in ALV, I can use the double click event for this. However, I do not want to use the Object Oriented ALV. I want to implement the same functionality using general (using functions) ALV.
    Is there any way to get the row / column values for a Generia (non-OOPs) ALV report.
    Please help.
    Thanks,
    Vishal.

    Hello,
    The only think you have to do is to get the index where the user clicked, and then read the internal table you sent to the alv
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program       = 'prg_name'
          i_callback_pf_status_set = 'SET_PF_STATUS'
          i_callback_user_command  = 'USER_COMMAND' " this is to the click event!!
          i_callback_top_of_page   = 'TOP_OF_PAGE'
          is_layout                = alv_layout
          it_fieldcat              = alv_fieldcat
          i_save                   = 'A'
          it_events                = alv_events[]
        TABLES
          t_outtab                 = i_totmez.  ---> TOUR IT.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    " then....
    FORM user_commandUSING r_ucomm     TYPE sy-ucomm
                                    ls_selfield TYPE slis_selfield.
    " r_ucomm -> HAS THE STATUS
    " ls_selfield-tabindex  -> HAS THE SELECTED INDEX
    " THEN READ THE INTERNAL TABLE
    " HERE YOU WILL HAVE THE SELECTED ROW
    READ TABLE i_totmez INDEX ls_selfield-tabindex.
    ENDFORM.
    cheers,
    Gabriel P.

  • How to display each character of an input string in different rows

    Dear Members,
    I want to write a SQL or PL/SQL where in I can separate and display each character of an input string into multiple rows.
    For eg, the input string is TESTING, I want the result to be displayed as following:
    1 T
    2 E
    3 S
    4 T
    5 I
    6 N
    7 G
    I know we can use substr, but it returns me only one or more than one characters consecutively.
    Please help me get the desired output.
    Thanks in advance.

    Hi,
    Perhaps
    with a as
    select 'TESTING' text from dual
    select level, substr(a.text,level,1)
    from a
    connect by level <= length(a.text)

  • How to repeat rows based on column value

    Hi all,
    I have a query that gives me a result with a column value for example 4.
    I now want to repeat this row 4 times with a new column that calculated from 1 - 4.
    Or when column value is 3 I want to repeat row 3 times with new column name 1-3
    Can anyone help me with this please? :)

    Hi Yvanlathem,
    To achieve your requirement, you can reference the recursive approach as below.
    DECLARE @T TABLE(Col1 CHAR(1),Col2 INT)
    INSERT INTO @T VALUES('A',1),('B',2),('C',3)
    ;WITH Cte([Char],[Repeat]) AS
    SELECT Col1,Col2 FROM @T
    UNION ALL
    SELECT [Char],[Repeat]-1 FROM Cte
    WHERE [Repeat]>1
    SELECT * FROM Cte ORDER BY [Char],[Repeat]
    OPTION(MAXRECURSION 0)
    /* Output
    Char Repeat
    A 1
    B 1
    B 2
    C 1
    C 2
    C 3
    If you have any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

Maybe you are looking for