Count of occurrences of ' " ' in string

Hi,
The answer to this is probably really obvious, but I can't work it out!...
I have a field in a table that holds a string of characters such as:
a"b"c"d"e"f
How can I return the number of occurrences of " (double quotes, not two singles) for each row?
Regards
Carl

Yeah, it was just new thing.
An other way working on 9i :
SQL> select nvl(length(trim(translate(mystr,translate(mystr,'" ', ' '),' '))),0) nb_double_quotes
  2  from (select 'a"b"c"d"e"f' mystr from dual);
NB_DOUBLE_QUOTES
               5
SQL> select nvl(length(trim(translate(mystr,translate(mystr,'" ', ' '),' '))),0) nb_double_quotes
  2  from (select 'a' mystr from dual);
NB_DOUBLE_QUOTES
               0Nicolas.

Similar Messages

  • Count the number of occurrence in a string

    is there any api for counting the number of occurrence in a string or should i write a method myself?
    for example. I want to count "." in "1.2.3.4.". i want to count the dot in this string.
    I am just wondering.
    Thanks in advance.

    is there any api for counting the number of
    occurrence in a string or should i write a method
    myself?The latter.

  • Getting count of occurances of a string in a column value

    Hi,
    Is there a way to get the number of occurences of a string in a single column value?
    Example:
    CREATE TABLE STRING_CNT(X VARCHAR2(100));
    INSERT INTO STRING_CNT(X) VALUES('OracleXXOracleXXOracleXXOracle');
    Commit;
    Now the string 'Oracle' is repeated 4 times in the inserted value. I would like to get this count using SQL.Can some one tell me how to get this?
    I was asked this interesting question in an interview today.

    hi<br>
    u can get the occurrence of a string in text as
    follow<br>
    >
    SELECT (LENGTH(x)-LENGTH(REPLACE(x,'Oracle', ' ' )))<br>
    / LENGTH('Oracle') as<br>
    Occurrence FROM STRING_CNT;<br><br>
    <br>
    Are you sure...?<br>
    <br>
    <br>
    SQL> with STRING_CNT as
      2  (select '1.Oracle2.Oracle3.' x
      3  from dual)
      4  SELECT (LENGTH(x)-LENGTH(REPLACE(x,'Oracle', ' ' ))) / LENGTH('Oracle') as Occurrence
      5  FROM STRING_CNT;
    OCCURRENCE
    1.66666667
    <br>
    Sidenote: Please give a try before posting..<br>
    And you are posting a wrong solution after a TESTED right solution posted hours before..                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Find the nth occurrence of a string in a string

    Hi,
    I'm wondering if there is a method like indexOf, but finds the nth occurrence of a string
    public static int occurrence(java.lang.String str,
                                 java.lang.String toFind,
                                 int occurrence)Cheers
    Jonny

    phdk wrote:
    calypso was refering to promes pseudo code.What is promes? I don't understand the word. Sorry!
    I put the global variable 'count' now in the method occurence
    public static int occurence(String str, String toFind, int occurence){
            int origLength = str.length();
            int count = 0;
            while(str.length()>0){
                str = contains(str, toFind, count);
                   if(count == occurence){
                    int length = str.length();;
                    int actualPos = origLength-(length+1);
                    return actualPos;
                   count++;
            return -1;
    public static String contains(String str, String toFind, int count){
            int occurence = str.indexOf(toFind);
            if(occurence != -1 ){
                 count = count+1;
                return str.substring(occurence+1,str.length());
            }else{
                return "";
      }The output is 1 position to high.
    I still don't get which part of the code to replace with this pseudo code: s'.indexOf('toFind', 'index'+1)
    Sorry for being dimwitted!
    Thanks
    jonny

  • How to count a occurence of a string in file

    import java.util.*;
    import java.io.*;
    class Count
    public static void main(String args[ ] )throws Exception
         FileReader fr=new FileReader("d:\\compfetch\\clean\\first.txt");
         BufferedReader br=new BufferedReader(fr);
         StringBuffer sb=new StringBuffer();
         while((s=br.readLine())!=null)
              sb.append(s);
         s=sb.toString();
    Vector v= new Vector();
         v.addElement("job");
         v.addElement("jobs");
         v.addElement("career");
         v.addElement("careers");
         v.addElement("vacancy");
         v.addElement("vacancies");
         v.addElement("opportunity");
         v.addElement("openings");
         v.addElement("posting");
         v.addElement("postings");
         v.addElement("opportunities");
         v.addElement("placement");
         v.addElement("placements");
         v.addElement("job");
         v.addElement("job");
         Enumeration vEnum=v.elements();
         while(vEnum.hasMoreElements())
              System.out.println(vEnum.nextElement());
    I need to count the occurence of each string given in the vector from the text file.I have the file and the vector.How do i compare the vector and textfile ,so that i can count the occurence of eachString in the vector with the text file.The text file may contain any of the words given in the vector.If found ,a count shld be made for each string .
    regards,
    koel

    Try this code:
    import java.util.*;
    import java.io.*;
    class Count
    public static void main(String args[ ] )throws Exception
         FileReader     fr = new FileReader("c.c");
         BufferedReader br = new BufferedReader(fr);
         StringBuffer   sb = new StringBuffer();
         String         s;
         while((s=br.readLine())!=null)
              sb.append(s);
         s=sb.toString();
         Vector v= new Vector();
         v.addElement("job");
         v.addElement("jobs");
         v.addElement("career");
         v.addElement("careers");
         v.addElement("vacancy");
         v.addElement("vacancies");
         v.addElement("opportunity");
         v.addElement("openings");
         v.addElement("posting");
         v.addElement("postings");
         v.addElement("opportunities");
         v.addElement("placement");
         v.addElement("placements");
         Enumeration vEnum=v.elements();
         while(vEnum.hasMoreElements())
              String l = (String)vEnum.nextElement();
              int    a = 0;
              int    p = s.indexOf(l,a);
              int    c = 0;
              while (p != -1)
                   c = c + 1;
                   a = a + l.length() + p;
                   p = s.indexOf(l,a);
              System.out.println(l+"  "+c);
    }

  • What function can be used to give a "count of occurrences of values" ?

    I would be very appreciative if someone in the user community could save me a few months of work....I've already been neck deep in my old statistics and calculus manuals. What function can be used to get the count of occurrences of the value of an item. Ex: Item is Status and possible values are "Published", "In Production", "Construction". In one report, I want to report all records of a table and list the Status (among other items) but at the total, I would like to see a count of each value for the item Status....something like Sum(Count(Status = "Published")) Sum(Count(Status = "In Production")) Sum(Count(Status = "Construction")). I know I could run the report 3 times counting a unique value, but I'm trying to be more efficient in my reporting. Thanks all for any help given.

    Hi
    In addition to John's answer, inside Discoverer you can do this:
    Let's assume you have a Status item and it has the values you mention. If you create the following new calculation SUM(ROWNUM) and name it Status Count you only need to include the Status and the Status Count in the worksheet. You will now see a count for each status.
    Best wishes
    Michael

  • [svn:fx-trunk] 13501: Bug: BLZ447 - AMF3 Deserialization: Wrongly counted reference ID of duplicated String when in the same message there are Strings with only wildcards

    Revision: 13501
    Revision: 13501
    Author:   [email protected]
    Date:     2010-01-14 06:01:23 -0800 (Thu, 14 Jan 2010)
    Log Message:
    Bug: BLZ447 - AMF3 Deserialization: Wrongly counted reference ID of duplicated String when in the same message there are Strings with only wildcards
    QA: Yes - please keep an eye on AMFX (HTTPChannel) tests.
    Doc: No
    Checkintests: Pass - except the usual 4-5 tests that time out on my machine.
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/rpc/src/mx/messaging/channels/amfx/AMFXDecoder.as

    Dear Pallavi,
    Very useful post!
    I am looking for similar accelerators for
    Software Inventory Accelerator
    Hardware Inventory Accelerator
    Interfaces Inventory
    Customization Assessment Accelerator
    Sizing Tool
    Which helps us to come up with the relevant Bill of Matetials for every area mentioned above, and the ones which I dont know...
    Request help on such accelerators... Any clues?
    Any reply, help is highly appreciated.
    Regards
    Manish Madhav

  • Count of occurences of a string senetence in 9i?

    Hi All,
    Is there an easy way using SQL to count the number of occrences of a string in a sentence? Dont want to use pl/sql if i can help it, maybe im missing an easy function?. Im using 9i rel2.
    eg find the count of ':' in the below string
    a:b:c:d: should return 4. (the separtor being : included on the end)
    a:b: should return 2
    and so on?
    Kind Regards
    Satnam

    SQL> SELECT a-LENGTH(REPLACE(SUBSTR(p,1,a),':',''))
      2    FROM
      3  (SELECT INSTR('a:b:c:d:e:',':',-1,1) a
      4         ,'a:b:c:d:e:' p
      5    FROM dual);
    A-LENGTH(REPLACE(SUBSTR(P,1,A),':',''))
                                          5Khurram

  • Report CO-PA: Count the occurrences of a characteristic

    In a report you want to count the occurrences of a characteristic relative to one or more other
    characteristics.
    For instance, we have a report whit two characteristics “customer” and “billing documents”, We have two columns, in the first one appears the "amount of sales", and in the second one "number of billing documents for each customer", I mean, we need a key figure that counts the number of “billing documents” per any other characteristic, such us customer.
    Has anyone any idea?
    Thanks in advance.
    Mariana Serrano

    Don't know why it does not work ... but I can say for sure that it worked fine on sys I've seen (both 2.x and 3.x): so check out SP for example.
    By the way I would like you to consider that working with exception aggregation at BEx level can be a performance pitfall, and even Virtual KeyF ...
    So be VERY carefull in evaluating the solution! With large InfoCubes you could have some surprise!
    Hope it helps
    GFV

  • Replacing occurrence of a string Using External tables??

    Hi,
    Is it possible to replace the occurrence of a string using external tables?
    For example, if you were loading a file that contained many fields. One of them was a description field. I want to be able to check this field for a string and if this string exists replace it with another.
    Is this possible with External tables?
    Thanks

    The external table can be used directly like a regular table using SQL if you defined it as PARALLEL 5.
    Access to external files is transparently parallelized, independent of the number of files (intra-file parallelism). The parallelism available through external tables increases performance dramatically compared to serial processing on a file-by-file basis.
    For more information:
    http://www.oracle.com/technology/products/oracle9i/daily/sept19.html

  • How do I count the number of occurrences of a string within a group of cells?

    Hello all, I'm trying to figure out how to count the number of times a child has completed certain tasks.  Here is a sample of the data (it is highly simplified here, but contains what I hope is needed to answer my question):
    Unnamed Table
    Objective
    John
    Ann
    Alex
    Dave
    Eric
    20a 20b 20c
    x
    20a 20b 20c
    x
    20a 20b 20c
    x
    x
    19b 20a
          x
           x
    20c 21b 22
         x
    What I am trying to do is count the number of times each child completed each objective - but I can't figure out how to go about splicing up the "objectives" fields for counting while still being able to compare them to whether or not the "child" has 'an x in the box' in that particular row.

    If I read your example correctly, John's counts should be 2 for 20a, 1 for 19b, 20b and 20c, and 0 for any other objectives listed.
    Here's an example that will work for your data set, assuming that any objective ma occur only once in each row of column A of the Main table. I've added an a to objective 22, but I think it is unnecessary, provided there is no objective 122, 221, etc.
    This uses a two step process.
    The table AUX extracts the objectives completed by each student, using the checkboxes in Main. Note that it also adds a space at the beginning and end of each string. This provides an extra character before the first objective code and after the last objective code in that row, used by the wildcard specification in the formula in the Summary table.
    Formula:
    Aux::B2: =IF(OFFSET(Data :: $A$1,ROW()-1,COLUMN()-1)," "&OFFSET(Data :: $A$1,ROW()-1,0)&" ","")
    Fill right to the last column and down to the last row of Aux.
    Summary uses COUNTIF to count the number of occurrences of each of the objectives listed in column A of that table.
    Formula:
    Summary::B2: =COUNTIF(Aux :: B,"=*"&$A2&"*")
    Fill right and down as the previous formula.
    Regards,
    Barry

  • How to count occurences of a certain string in incoming real-time data? Also displaying RTC data. Current VI included

    I use LabView student Express 7 on a Windows XP system.
    Time-frame: we are doing final integrations for our balloon experiment today. We just got told that the press wants to view real-time data, which we haven't programmed for. I need help to get a working VI at the latest by 25.02.2004 before 0800(morning) (GMT+1).
    Note on license
    It is a student balloon flight, and the data will not be used in scientific work, so the I am not breaking any license agreements (I hope).
    Problem synopsis:
    The balloon continually transmits data at 9600baud. The data is a semi-repeating header followed by a constant lenght data-package arranged like this:
    BEXUS[h][m][s]BEXUS[h][m][s]
    [Raw binary data, 7channels*8sub-channels*8bits]
    What the groundstation is doing right now:
    Take all incomming data and save (append) the data to a file without any data-handling. (We figured we would go post-processing).
    What I need to change in less than 24 hours:
    - Add a "package" counter
    - Add a display of the clock data (RTC)
    How I planned to implement the changes:
    -RTC display:
    The RTC data is in BCD format, since that means that if you look at the data as hex numbers, you get the hours and minutes and seconds out in "clear text". That is 12 hours is 0x12hex. I figured that I can do a match pattern BEXUS and pass the "after substring" to another match pattern BEXUS from which I feed the "before substring" to a type-cast VI (casting string to u8) and displaying that, which should give me a display of "123000" for the time 12:30:00... I couldn't get it to work at all when I tried out the supplied "beta" vi.
    - Package counter:
    Counting how many BEXUS that gets detected and dividing by 2. I don't know how to do this. I've looked on the forum (a good thread on the problem: "how do I count the number of *'s in a string") but these use either loops or arrays... and I'm not sure how this works when I'm getting the data in at realtime. I cant make an array and then count it, since then the array would grow fast and possibly interfere with saving of the data??? Saving the data is critical.. without that file we cant do post-processing.
    Since my time is so limited (I'm not even supposed to do the groundstation software but they called on me in the last minute because no-one else had time/wanted too/could do it) I hope that you could make an exception and provide me with working VI's (based on the one I have attached) so that I can show something to the press! (Free comercial for NI!! Since the student version shows the National Instruments water-mark on all VI's!!! Possible TV time!!)
    Thanks!
    PS: even if you are to late (after 25) post anyway!
    Why:
    -I can learn from it
    -the launch might be delayed due to weather conditions
    -others might find it amusing!
    Thanks again!
    Attachments:
    BexusII_groundstation.vi ‏46 KB

    I have a valid example data file attached to this thread.
    If you open BEXTEST.bin in a hex-editor of your choice, you'll see the BEXUS as 42 45 58 55 53 and then the time as 00 28 09 etc.
    I couldn't get Joe Guo's VI to work. It doesn't count packages correctly, and the time is not displayed correctly either.
    The file was saved using a straight save to file VI.
    The data is from actual launching area tests performed a few mintues ago. The time displayed is "On time" e.g. how long the gondola has been powered up.
    I have a spare T-junction, so I can hook into the balloon real-time data as we fly, in case anyone care to see if they can figure out why the latest version of Joe Guo's program is not displaying correctly.
    I will monitor this
    thread during and after flight to see if anyone can make it in time!
    Thanks for the great effort!!
    Attachments:
    bextest.bin ‏53 KB

  • Count of character in a string

    Hi,
    Here is a string.
    Str = 'test,123,1-Jan-2008',sql,oracle,test,date
    Can we count the number of commas(,) in the above string without passing it to any loop? I want to use replace/translate and length for this purpose.
    Regards,
    Ritesh

    SQL> var a varchar2(500)
    SQL> exec :a := '''test,123,1-Jan-2008'',sql,oracle,test,date'
    PL/SQL procedure successfully completed.
    SQL> print a
    A
    'test,123,1-Jan-2008',sql,oracle,test,date
    SQL> select length(:a)-length(replace(:a,',')) comma_count
      2    from dual
      3  /
    COMMA_COUNT
              6

  • Counting particular character in a string

    Hi all
    how can we count the number of characters in a perticular string in simple SQL statement
    example
    how many commas are there in this string 'a,b,s,d,e,f,g,h'

    select length('a,b,c,d,e')-length(replace('a,b,c,d,e',','))
    from dual

  • Counting the character in a string

    How to find the number of repeated characters in a string
    example- 'RAJA' In this string how many 'A' are there

    A beautiful query posted by a guru in this forum long time ago.
    SQL> set line 1000
    SQL> l
      1     SELECT ename
      2          , Letter_repetition
      3          , COUNT(*)repetition_count
      4     FROM ( SELECT ename
      5                   , Letter_repetition
      6                FROM emp
      7               MODEL
      8                     RETURN UPDATED ROWS
      9                     PARTITION BY (ename)
    10                     DIMENSION BY (0 i)
    11                     MEASURES (ename Letter_repetition)
    12                     ( Letter_repetition[FOR i FROM 1 TO
    13                                         length(Letter_repetition[0])
    14                                         INCREMENT 1] = SUBSTR(Letter_repetition[0],CV(i),1)
    15                     )
    16             )--End of FROM clause
    17      GROUP BY ename
    18          , Letter_repetition
    19*    HAVING COUNT(*) > 1
    SQL> /
    ENAME                               LETTER_REPETITION                   REPETITION_COUNT
    SCOTT                               T                                                  2
    TURNER                              R                                                  2
    ALLEN                               L                                                  2
    MILLER                              L                                                  2
    ADAMS                               A                                                  2
    SQL>

Maybe you are looking for

  • Premiere Elements 3 with Windows 7

    I have been using Premiere Elements 3.0 with windows XP and it has been sufficient for what I want to do. I have now upgraded to Windows 7 and the disk will not reinstall the program. I noticed that there was an update for Vista of Premiere Elements

  • How can I allow or block the use of local storage by specific sites for all users in my domain.

    How can I allow or block the use of local storage by specific sites for all users in my domain. I tried to do this by MMS.cfg but it is not working, the problem is also described in your blog "http://forums.adobe.com/message/3272907". What I Want -:

  • What causes my kernel panic?

    Several times a week my Mac crashes. I have not been able to provoke a crash; they seem random. The latest report and the result of Etrecheck follows: Anonymous UUID:       55B586BC-C531-9F38-57F5-B5A84DEBFF83 Sun Apr 12 15:37:19 2015 *** Panic Repor

  • Please help in creating query

    I have 3 tables 1. Person table. The columns are PersonID, PersonName and isActive . PersonID is the primary key 2. Vendor Table The columns are VendorID and VendorName. VendorID is the primary key 3. Vendor_Prod table The columns are Ven_prod_id,Ven

  • Invoice correct issue

    Hi Experts, I have a sceanrio where the flow is QT , So DEL, Invoice , here in the order at the header and Item level i find Gross proce condition is found in the Conditions, but when I check in  the Invoice correction Request and Invoice Correction