How to count characters from string

I have a string like
a, a, b, b, s, a, a, b, ba

requried out put is
County (a) = 5
and (b) = 4 count
County (in) = 8


Thanks and greetings
kesana Niasse
if your db version is Oracle 11g,

you can use below one,

SELECT regexp_count('a,a,b,b,c,c,d,d,e,a,a,b,d,c','a') a_count,
  regexp_count('a,a,b,b,c,c,d,d,e,a,a,b,d,c','b') b_count,
  regexp_count('a,a,b,b,c,c,d,d,e,a,a,b,d,c','c') c_count,
  regexp_count('a,a,b,b,c,c,d,d,e,a,a,b,d,c','d') d_count,
  regexp_count('a,a,b,b,c,c,d,d,e,a,a,b,d,c','e') e_count
FROM dual;

and output will be
a_count|b_count|c_count|d_count|e_count
4         |   3       |    3      |    3      |1

Tags: Database

Similar Questions

  • How to count characters in Notepad?

    I need to write a script in Notepad, and I also need to make sure I'm not more than 5500 characters. How to count characters? I can't find a button to do it.

    Select all, then copy. Paste it into this online character counter
    http://www.webworldindex.com/countcharacters.htm

    Check again if necessary.

    Bruce Hagen
    MS - MVP October 1, 2004 ~ September 30, 2010
    Imperial Beach, CA

  • Remove the unused characters from string

    Hi, I try to remove unused characters from a string, but I can't find a function for this.

    The string like: 0000 0000 0000 0000 0000 0000 0130 3130 3030 3030 3004 0000 0000 0000 0000 0000 0000 0000, I need the characters from 01 to 04.

    I need some advice.

    If the characters between the SOH and EOT had a NULL value, then Match Regular Expression can be a choice:

    Find \x01, find something else THAN \x04, then find \x04

  • How to remove characters from a file name using applescript

    Hello

    I use an AppleScript to write files from an application.

    The files are written as JPEG and PDF files

    I want to omit parts of the name of the JPEG file

    Name of the file looks like this, 70618_MEN_327926_2200x3480_1.jpg

    I need to be renamed on output, 327926_1

    That is to say, delete all characters to the end of the second line of underscores, so all characters after the third underscore and leave all the characters after the fourth underscore character.

    Hello

    You can use a Manager, like this (Manager contains explanations):

    ------------------------

    tNom set to "70618_MEN_327926_2200x3480_1.jpg".

    Set newName to my getChars (tName)

    -the result is "327926_1.jpg".

    on getChars (t)

    value {oTid, point text delimiters} {text item delimiters, '_'}

    the entire at t text elements - divide the text using the line underscore as separator, the result is a list of items

    If (count l) > 4 then - at least 4 characters to underscores

    the charsAfter4_ value to (points 5 thru - 1 l) in the form of text - the text after the fourth underscore

    the value charsBetween2_3_ in section l 3 - the text between the second and the third underscores

    the value t charsBetween2_3_ & "_" & charsAfter4_ - concatenate two strings

    end if

    set the text of the delimiters to oTid - reset point of text delimiters

    return t

    getChars end

  • How to remove characters from desried place?

    Hi all;

    I need to remove the 2nd character desired to delete.
    ex-"123 - 2335-456", I need to delete 2nd onve '-' IE South result be-'123-2335456 ".

    How, without use of substr/instr to get 2nd place of "-"...


    Rgds,
    PC

    What is your version of db. If you can use regexp, you can do

    select regexp_replace('123-2335-456','-','',1,2) from dual
    
  • How to capture characters from video games on a white background?

    So I honestly don't know where to start. I am a beginner to AE and wanting something very basic, but don't know what to ask. Also will be the link of a creator and I'm looking to do something similar.

    Want to ENB - YouTube

    I am only concerned about the first 8 seconds of youtube video. How can you take pictures of a video game (something I already selected) and drop on a white background to create a clever title? I don't mean to guide step by step, but just something or someone to point me in the proper direction.

    Thanks advance!

    -PL

    If you happen to have the background without character in (what is called a "clean plate"), you can use a cache of difference.

    Otherwise, it's good, old rotoscoping.

  • I have Adobe Acrobat Pro XI.  I went to special characters from the Edit menu and choose some emoji as Favorites, but I can't understand how to insert in the document.  How can I insert special characters into a document?

    How can I insert emoji or other special characters in a document using Adobe Acrobat Pro XI?  I went to special characters from the Edit menu and may not understand how to insert the special character in the document.

    He's not that kind of editor. You can use the characters in a font. If you can select a font with the emoji, which fits into the case, and then enter the characters, it can work.

    This suggests that you try to do TOO MUCH with a PDF file. It is a common thing, but the message should be: everything simply because you can edit a PDF file, does not mean that it is the most effective way for you to do your job.

  • extract characters from a string

    Hi gurus,
    I want to extract the first, third, fifth, seventh... characters in a string.
    not to extract characters from a subset of characters in a select query in oracle 9i database.

    for example (1):
    Assume that a string like this "SUE" is that I am 'ACEGI"of the source string
    and the source can be any valid string, I just give an example here.

    Example (2) of "kalpataru' in klatau'

    Please guide me for this

    for 9i:

    SQL> with t as (
     select 'ABCDEFGHIJ' str from dual union
     select 'kalpataru' from dual
    )
    --
    --
     select str,
            trim(extract(xmlagg(xmlelement(e, substr(str,level,1)) order by level),'//text()')) str2   from t
      where mod(level,2) = 1
    connect by level <= length(str) and prior str = str and prior sys_guid() is not null
      group by str
    /
    STR        STR2
    ---------- --------------
    ABCDEFGHIJ ACEGI
    kalpataru  klaau         
    
  • How to get data from HTTP connection string?

    First of all, I have a PHP page that establishes the connection and the query to the database to get a random string in the database and printing on the page, say the name is: getString.php, such as every time that you refresh the page, the string that is printed on this page can be (or most of the time) different. The next step I wanted to do is to get this string and put it on my application for Blackberry, and I do not know how.

    I use WAP2 for the connection, and I copied the code that is shown here:

    http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800563/What_Is...

    So once the connection is established, how can I get the string content in this page? I had the url of http://mydomain.com/getString.php

    Thank you!

    Why don't you use a StringBuffer?

  • How to store characters in result file and display on front panel

    Hello

    currently I am working on the FPGA project.i want data acquired from FPGA board.i want to know on how to store characters to the file and contineous each character display on the façade in the string format.

    I'm full up to characters on the front display, but display characters only when I want all characters in string format.

    I don't see how this question fits in any digital i/o, but it looks like you just need a change of register with the concantanate string function.

  • How to count the tank &amp; number?

    Hi all

    11.2.0.1

    I have an EMP table with column EMPID (varchar2 (15))

    It contains the values of numbers and characters.

    For example:

    5365

    cllaurena

    6356

    5365

    csroxas

    fstang

    1010

    cuermita

    fstang

    How to count all the digital and all characters, or a group of tank and the number without creating features?

    Thank you all,

    PK

    Are you after something like this?

    WITH t
         AS (SELECT '5365' str FROM DUAL
             UNION ALL
             SELECT 'cllaurena' FROM DUAL
             UNION ALL
             SELECT '6356' FROM DUAL
             UNION ALL
             SELECT '5365' FROM DUAL
             UNION ALL
             SELECT 'csroxas' FROM DUAL
             UNION ALL
             SELECT 'fstang' FROM DUAL
             UNION ALL
             SELECT '1010' FROM DUAL
             UNION ALL
             SELECT 'cuermita' FROM DUAL
             UNION ALL
             SELECT 'fstang' FROM DUAL)
      SELECT CASE
                WHEN LENGTH (TRANSLATE (str, '~0123456789', '~')) IS NULL
                THEN
                   'num'
                ELSE
                   'not_number'
             END
                typ,
             COUNT (*)
        FROM t
    GROUP BY CASE
                WHEN LENGTH (TRANSLATE (str, '~0123456789', '~')) IS NULL
                THEN
                   'num'
                ELSE
                   'not_number'
             END;
    

    TYPE COUNT (*)

    ------------------------------------------

    num                  4

    not_number 5

    See you soon,.

    Manik.

  • How to read continuously from the rs232?

    Hello

    I'm new to LabVIEW and my questions would be obvious for some for you. So please help if you know the solution.

    It's for my school project. For your information, we need to schedule a Committee of Altera DE2 to control traffic lights (something like that) and at the same time, the Commission shall forward the States of enlightenment to a computer with LabVIEW installed via an RS-232 cable.

    The rest of the project was fine except for the part of LabVIEW, because as I said earlier, I'm new to LabVIEW.

    We use the "basic series write and Read.vi" in the folder examples of NEITHER. The problem is that we do not know how to change the vi in order to receive the data that come the DE2 Board permanently. Each time, the vi stops reading after receiving 24 bytes of data.

    So, the first question is:
    1.) how to read continuously from the RS-232 port? (We tried to use while "loop" but without success, maybe we were doing it the wrong way.) If you know the solution, please enlighten us for us in a detailed manner.

    (2) Secondly, once we have received the 'chain', how can convert us to bits (0 and 1) so that we might be able to manipulate the bits, for example turn on the LEDs that correspond to the bits.

    Thank you.

    Instead of reading the bytes of the port so to read that many bytes (which may be zero), just do a VISA read for 1 byte.  He will wait for this next byte.

    To get an array of Boolean out of this byte, use this code.  He turns the characters into a byte array.  Takes the first and the only element of this array, and then converts this single U8 number into an array of bytes.

    Which country are you?  I've never seen or heard lights orange before.  Only the yellow lights.

  • How to convert times from second to hh with CVI

    How to convert times from second to hh with CVI?

    Can anyone advice?

    It's here. As I told you, it's very simple:

    //----------------------------------------------------------------------
    // Function secToHMSstring ()
    //----------------------------------------------------------------------
    /// HIFN secToHMSstring ()
    /// HIFN The function takes an amount of seconds and returns a string with
    /// HIFN the corresponding value in H:M:S format
    /// HIPAR sec/Value in seconds to convert
    /// HIPAR verbose/If True use "hms" separators; if not, use ":" separator
    /// HIPAR string/The output string. It is responsibility of the programmer
    /// HIPAR string/that the string is large enough to keep the resulting text
    /// OUT string
    void secToHMSstring (int sec, int verbose, char *string)
    
    {
        int     hh = 0, mm = 0, ss = 0;
    
        if (sec >= 3600) {
            hh = sec / 3600;
            sec -= hh * 3600;
        }
        if (sec >= 60)
            mm = sec / 60;
        ss = sec - mm * 60;
    
        strcpy (string, "");
        if (verbose) {
            if (hh > 0) sprintf (string, "%s%dh", string, hh);
            if (mm > 0) { if (strlen (string)) strcat (string, " "); sprintf (string, "%s%dm", string, mm); }
            if (ss > 0) { if (strlen (string)) strcat (string, " "); sprintf (string, "%s%ds", string, ss); }
        }
        else {
            if (hh > 0) sprintf (string, "%s%d:", string, hh);
            if (mm > 0) {
                if (strlen (string)) sprintf (string, "%s%02d:", string, mm); else sprintf (string, "%d:", mm);
            }
            else if (strlen (string))
                strcat (string, "00:");
            if (strlen (string)) sprintf (string, "%s%02d",  string, ss); else sprintf (string, "%d", ss);
        }
    
        return;
    }
    
  • How to remove clouds from an old computer

    One of my copmputers is not in use. How can I delete from there so that I'll be able to use it on another computer? @

    You really need to log on the old computer, uninstall will not count insofar as it frees up to another machine.

    Sign out, sign in | Creative office cloud app

    http://helpx.Adobe.com/creative-cloud/KB/sign-in-out-creative-cloud-desktop-app.html

    Help of activation & deactivation

    https://helpx.Adobe.com/x-productkb/policy-pricing/activation-deactivation-products.html#a ctivate-how-to's

  • How to count the number or lines in the file

    Hi Experts,

    I'm file as source and Oracle as target. My folder that contains some data that will load the target.
    My requirement is that I want to count the number of lines that contains my folder. Please help me how to count the total number of lines in the file.


    THX,
    Sara.

    Hi Sahaveda,

    Now, I tried and it works.

    Sorry my mistake again.

    I created HR. ETL_FILE_LOG as below:

    CREATE THE TABLE HR. ETL_FILE_LOG (numero_fichier varchar2 (10))

    Below the code will run without error:

    import java.lang as lang

    import java.sql SQL

    import of java.lang.String

    Import os

    disadvantages is sql. DriverManager.getConnection ("<%=snpRef.getInfo("DEST_JAVA_URL")%>", "<%=snpRef.getInfo("DEST_USER_NAME")%>", "<%=snpRef.getInfo("DEST_PASS")%>")

    dblinks = cons.createStatement)

    File1 = Open ('c:\EMP.txt','r')

    Count = 0

    Line = file1. ReadLine()

    all online! ='' :

    Count += 1

    Line = file1. ReadLine()

    File1. Close()

    sqlQuery = "insert into HR. "The values of ETL_FILE_LOG (numero_fichier) (" + str (count) + ' ") '.

    rqQuery = dblinks.execute (sqlQuery)

    jerks. Close()

    Concerning

Maybe you are looking for