How do count how many 'A' s in this string using sql stmt?

hi all,
i have a string like 'AAAAARAMAAAAKRISHNAAAA'.
in this ,i want to find out how many 'A's .
how do find out this using select stmt.

(length(s) - nvl(length(replace(s, 'A')), 0)) / length('A')but consider (by modifying the question slightly to "how do count how many 'AA' s in this string using sql stmt? ")
SQL>  select (length('AAAAARAMAAAAKRISHNAAAA') - nvl(length(replace('AAAAARAMAAAAKRISHNAAAA', 'AA')), 0)) / length('AA') x from dual
         X
         6
1 row selected.couldn't I argue that the result should be 10 as e.g. in
SQL>  select * from xmltable('let $str := "AAAAARAMAAAAKRISHNAAAA"
                        let $search := "AA"
                        for $i in 1 to string-length($str)
                          where substring($str, $i, string-length($search)) = $search
                          return substring($str, $i, string-length($search))' columns x varchar2(10) path '.')
X        
AA       
AA       
AA       
AA       
AA       
AA       
AA       
AA       
AA       
AA       
10 rows selected.Matter of definition I suppose .... ;)
btw. regexp_count also yields 6:
SQL>  select regexp_count('AAAAARAMAAAAKRISHNAAAA', 'AA') x from dual
         X
         6
1 row selected.

Similar Messages

  • How to count how many times the caller calls by using UCCX script?

    Hi there,
    My customer wants to do a few changes for their script as below:
    At the beginning of the script they are planning to add a new menu item, it will announce their new privacy policies and to continue the user must press the number one to continue to the Welcome.  If they do not press 1 then the message should repeat itself and if they again do not press 1 they should be transferred over to a live operator who will explain things and then be able to transfer them back to the message so that they can press 1 and continue.
    I modified their script as attached file, but i don't know how to count how many times the caller calls in "Get Reporting Statistic".
    Any helps would be appreciated.
    Thanks.

    Hi Aaron,
    At beginning, i want to use a variable to get number of mistake for the same caller, then we will send the call to right place to fulfill the customers' needs. 
    Do you have any suggestion for the new posted script?
    Thanks.

  • How to count " How many times the ' commit work ' Statement is executed.

    Hi all sap Champions,
    One of the client requirement, That is
    How to count " How many times the ' commit work ' Statement is executed.
    It's urgent.
    Please can anybody help me for this.
    Thanks
    Basu

    hi,
    when report try like this.
    declare a variable as
    data: counter type i value 0.
    COMMIT.
    counter = counter + 1.
    write:/10 counter 'NO. OF TIMES COMMIT WORKED'.

  • How to get this output using sql query?

    Hi,
      How to get this output using sql query?
    Sno Name Age ADD Result
    1 Anil 23 delhi Pass
    2 Shruti 25 bangalor Pass
    3 Arun 21 delhi fail
    4 Sonu 23 pune Pass
    5 Roji 26 hydrabad fail
    6 Anil 28 delhi pass
    Output
    Sno Name Age ADD Result
    1 Anil 23 delhi pass
    28 delhi pass

    Hi Vamshi,
    Your query is not pretty clear.
    write the select query using Name = 'ANIL' in where condition and display the ouput using Control-break statements.
    Regards,
    Kannan

  • How to count number of repeated characters in a String

    I have a String.... 10022002202222.
    I need to know how many 2's are there in the string... here the string contains eight 2's..
    Thanks in advance..

    it is workingYes, but... attention to surprises...
    SQL> var v1 varchar2(1000);
    SQL> exec :v1 := 'How to count the number of occurences of a characters in a string';
    PL/SQL procedure successfully completed.
    SQL> select length(:v1) - length(replace(:v1,'c')) from dual;
    LENGTH(:V1)-LENGTH(REPLACE(:V1,'C'))
                                       6
    SQL> exec :v1 := 'cccccc';
    PL/SQL procedure successfully completed.
    SQL> select length(:v1) - length(replace(:v1,'c')) from dual;
    LENGTH(:V1)-LENGTH(REPLACE(:V1,'C'))
    SQL> select length(:v1) - nvl(length(replace(:v1,'c')),0) from dual;
    LENGTH(:V1)-NVL(LENGTH(REPLACE(:V1,'C')),0)
                                              6
    SQL>

  • How to have more than one condition on same column --- using SQL Loader

    Hi All,
    I am stuck with SQL Loader..
    How do I filter records before loading in the table using when clause..
    i should load data only when
    field1 = 'AC' or 'VC'
    field2 is NULL
    i used various combinations in when clause like
    a) when field1='AC' or field1='VC' and field2 = BLANKS
    b) when (field1='AC') and (field2 = BLANKS )
    & similar...
    In all the cases I tried I could not implement OR condition with field1 and null condition with field2
    but my main concern is can we use OR or IS NULL things in when clause of SQL Loader..
    is it possible to check this anywhere??
    any alternate solution u could suggest??
    Thanks
    Dikshit

    Ok I'll try that, although I did try it earlier when I had iTunes 5.xx loaded, I think.
    As to size of playlists, I have a master (900 songs) that defines what will fit onto the ipod , I then generate all the others as subsets of the master (not of the library)- hence I know they will all fit
    Can you also clarify something for me: the dialogue box we are discussing is intended, I think, so that one can set the automatic synching of certain playlists between the PC & the ipod. Is that the only way one can select other playlists to go to the ipod - i.e. as static once-offs, not synchronised ?
    Apple' docs, I think, are poor in this regard - they assume most ipods are bigger then the users song library and they gloss over the details of this alternate mode of playlist synching.
    Thanks - Nick

  • How to split a string using sql

    Hi All,
    I've to write a query where I need to split a string, how this can be done? So let's say a column has value as 1,2,3,4,5 and I want to split this string and output it as:
    1
    2
    3
    4
    5
    Please advise.

    Lots of articles:
    Snap this user defined function too:
    CREATE FUNCTION [dbo].[ufn_SplitString_Separator](@InputStr VARCHAR(MAX), @Separator VARCHAR(1))
    RETURNS @tmpTable TABLE (OutputStr VARCHAR(MAX))
    AS BEGIN
    DECLARE @TmpPOS integer
    SET @TmpPOS = CHARINDEX(@Separator,@InputStr)
    WHILE @TmpPos > 0 BEGIN
    IF @TmpPos > 0 BEGIN
    INSERT INTO @tmpTable VALUES (LTRIM(RTRIM(SUBSTRING(@InputStr,1,@TmpPos-1))))
    SET @InputStr = SUBSTRING(@InputStr, @TmpPOS + 1, LEN(@InputStr) - @TmpPos)
    SET @TmpPOS = CHARINDEX(@Separator,@InputStr)
    END ELSE BEGIN
    INSERT INTO @tmpTable VALUES (LTRIM(RTRIM(@InputStr)))
    SET @TmpPos = 0
    END
    END
    IF LEN(@InputStr) > 0 BEGIN
    INSERT INTO @tmpTable VALUES (LTRIM(RTRIM(@InputStr)))
    END
    RETURN
    END
    GO
    And you can use like this:
    SELECT * FROM DBO.[ufn_SplitString_Separator]('1,2,3,4,5',',')
    "If there's nothing wrong with me, maybe there's something wrong with the universe!"

  • Hiii, i have m rows & n columns in my table..how to convert it into m columns & n rowa by using sql..pls help me...thanks.

    hiii,
    I have a table which has 14 rows & 8 cols.
    I want covert it into 14 cols & 8 rows,
    by using sql how to do it..pls help me.

    Oracle Database Search Results: pivot

  • How to disable the archive logs in SAP IDES(Windows) using SQL Server

    can any body tell us How to disable the archive logs in SAP IDES(Windows 2003) using SQL Server 2000.SP4.?

    Hi,
    Unfortunately, SQL Server does not have the option to turn off transaction logging. You can set the recovery mode to SIMPLE, instead of FULL. This will result in the transaction log being truncated on checkpoint.
    http://support.microsoft.com/kb/873235 - check this microsoft article
    This will help in reduction of the size of the transcation log.
    - Regards, Dibya

  • How to look for a certain value in a database using sql

    Hello everyone. How do you do this in SQL? Or, is there a way to look for a certain value in a database? What I'm trying to do is this:
    I want to look for the exact value "abcdefg" in the database so that oracle will return me details on the following that contains the said value:
    1. the name of the table(s)
    2. the column/field name(s)
    Note: "abcdefg" could exist in different tables with different column names with different data types.
    Any help is much appreciated. Thanks.
    UPDATE: What about if I just want to check those fields/columns with string data types?
    Message was edited by:
    dongzky
    Message was edited by:
    dongzky

    Just a teeny tweek
    DECLARE
       l_dummy   VARCHAR2 (4000);
    BEGIN
       FOR rec IN (SELECT table_name
                     FROM all_tables)
       LOOP
          FOR rec2 IN (SELECT column_name
                         FROM user_tab_cols
                        WHERE table_name = rec.table_name)
          LOOP
             BEGIN
                EXECUTE IMMEDIATE    'select 1 from '
                                  || rec.table_name
                            || ' where to_char('
    || rec2.column_name
    || ') = ''CAS'' and rownum = 1'
                             INTO l_dummy;
                DBMS_OUTPUT.PUT_LINE (rec.table_name || ' ' || rec2.column_name);
             EXCEPTION
                WHEN NO_DATA_FOUND
                THEN
                   NULL;
             END;
          END LOOP;
       END LOOP;
    END;

  • How to specify a particular index for DB2 database when using SQL in ABAP

    Is this format for Oracle?
      select *
       into -
       from  vbrk CLIENT SPECIFIED
    where erdat in erdat
        and mandt EQ sy-MANDT
        %_HINTS ORACLE 'INDEX("VBRK" "VBRK~ZER")'
    For the index 'VBRK~ZER' was defined before,it only includes one field 'VBRK-ERDAT'.
    How can i tell Sap to use this index while processing SQL in DB2?
    Thanks advance.

    There are different hints for the different database platforms.
    For up-to-date information please read the SAP notes, search 'hint DB2'.
    Siegfried

  • How do I quickly generate a list of all servers using SQL Server 2005 thru 2014 with CPU & Core Information

    Hello,
    My manager wants this information ASAP for licensing reporting.
    This seems to run forever, even when I include a list of IPs.
    I am using version 9.2 of MAP
    Thank you very much,
    Mike

    jschell wrote:
    flyto9 wrote:
    I'd been told to create a user friendly no brainer user interface In typical business scenarios involving databases that is ridiculous.
    A company that has multiple database servers must ALREADY understand the complexities of managing and using those databases.
    true, but you know as well as I do that requirements documents are usually not written by people with the least understanding on those complexities...
    And if a company assigns such a project to someone like OP who clearly doesn't know how to deal with such requirements documents, that only shows their morosity all the more clearly :)
    Assuming that I'm able to find a list of TCP connections on network, how do I know which of them are sqlserver?That isn't what I said. A "protocol" is a description of a methodology involving functionality and communication which solves a particular problem.
    There is a "protocol" which describes how to find MS SQL Servers. You don't make it up yourself. You find the description, read what it says and implement it.Or more likely (like Oracle) there's no such security problem in MS SQL Server and instead it relies on the client knowing the connection details or it'll never find them.

  • How can i store a picture file in a table using sql

    can anyone help me
    to store a pic file in a table using sql

    You can find an example in this link
    http://www.orafaq.com/forum/t/38347/0/

  • How can I find out what is causing this error in SQL Developer Data Modeler

    Friends,
    I am trying to import entities into into SQL Developer Data Modeler from Oracle Designer 10.1.2.3.
    In case of need I perform these steps to perform the import:
    File --> Import --> Oracle Designer Model --> Select database connection --> Select work area --> select application system --> select one entity --> Click finish --> Import starts
    During the import process I see an alert dialog box with the message:
    There are errors in import - check Log file Clicking Ok dismisses the alert box and I see the following summary screen:
    Oracle SQL Developer Data Modeler Version: 2.0.0 Build: 584
    Oracle SQL Developer Data Modeler Import Log
    Date and Time: 2010-08-09 14:27:26
    Design Name: erdtest
    RDBMS: Oracle Database 10g
              All Statements:           32
              Imported Statements:      32
              Failed Statements:           0
              Not Recognized Statements:      0The Entity is then displayed in the Logical View within SQL Developer Data Modeler.
    Upon checking the log file I see the following entry:
    2010-08-09 13:50:34,025 [Thread-11] ERROR ODExtractionHandler - Error during import from Designer Repository
    java.lang.NullPointerException
         at oracle.dbtools.crest.imports.oracledesigner.logical.ODORelation.createArcs(Unknown Source)
         at oracle.dbtools.crest.imports.oracledesigner.logical.ODORelation.generate(Unknown Source)
         at oracle.dbtools.crest.imports.oracledesigner.ODExtractionHandler.generateDesign(Unknown Source)
         at oracle.dbtools.crest.imports.oracledesigner.ODExtractionController$Runner.run(Unknown Source)
         at java.lang.Thread.run(Thread.java:619)Can anyone shed any light on this error?
    Thanks in advance for any help you may be able to provide.

    No this helps a lot. It's not strange. Firstly, in a versioned repository you should see Private Workareas and Shared workareas, so your workarea may be in either of these. It won't be in the Global Shared Workarea, as this only for non-versioned repositories. (I like to open the RON by selecting the full Repository, that way I can see the private and shared worlareas and the configuration and containers all in the same tree.
    Now your workarea is defined by a set of rules, so when you expand the workarea in the RON, and select the object, then that's the workarea and object you'll see in the import dialog in the Data Modeler. So if you check it out and check it back in, and can't see it in the RON, then the rule is not seeing this object. (Did you refresh the workarea in the RON?) If you can't see it in the RON, you can't see it in the Data Modeler. If you're working in a versioned repository, you need to work in the specific work area, i.e V27 and this is what you need to select in the Data Modeler.
    It looks like you are selecting the wrong workarea in the Data Modeler.
    Sue

  • How to get the WHOLE xml document inside a string using XSLT mapping

    Hi folks,
    I have a deep xml structure that I want to embed as body, tags included, in a mail message (not as an attachment).
    I'm trying to use Michal's method in this blog
    /people/michal.krawczyk2/blog/2005/11/01/xi-xml-node-into-a-string-with-graphical-mapping
    However, I can't get it to deliver the entire structure instead of just specific elements.
    Any help is greatly appreciated,
    Thanks,
    Guy

    Ashok,
    I was able to work it out for my case.
    This XSL......
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
    <inside>
    <namestring>
    <xsl:text disable-output-escaping="yes"><![CDATA[<![CDATA[]]></xsl:text>
    <xsl:copy-of select="outside/name/*"/>
    <xsl:text disable-output-escaping="yes"><![CDATA[]]]]></xsl:text>
    <xsl:text disable-output-escaping="yes"><![CDATA[>]]></xsl:text>
    </namestring>
    </inside>
    </xsl:template>
    </xsl:stylesheet>
    ...will transform this input....
    <?xml version="1.0" encoding="UTF-8"?>
    <outside>
    <name>
    <nameone>name1</nameone>
    <nametwo>name2</nametwo>
    <namethree>name3</namethree>
    </name>
    </outside>
    ...and put the whole lot into the CDATA element.
    Hope this helps you,
    Guy

Maybe you are looking for

  • G5 no longer recognizes monitor properly

    This post is about a Gateway monitor, not an Apple monitor, but the Gateway folks said the issue is with the computer. So I apologize if I'm in the wrong place, but I need some help and I couldn't find an appropriate forum. I have a Gateway FPD1975W

  • Oracle installation on aix

    hello, i am on a project where i need to install oracle 10gr2 on aix 6.1. the issue i am looking at right now is this we already install oracle 10gr2 the server using a particular partition now i want to install oracle 10gr2 on the same server but a

  • Use of DEFAULT tablespace while re-enabling constraint

    Using 8.1.7.2. While trying to re-enable a constraint on a table, we hit a ORA-01630. According to the error message, Oracle was trying to use the DEFAULT tablespace (USERS) instead of the TEMPORARY tablespace (TEMP) to do the work. Why would Oracle

  • Futureproof and dynamically created button

    I have been looking solution how to make buttons dynamically so that I can fetch dynamically values for buttons: - value,onclick,class,type,request This excellent page has very closely what I am looking: http://www.laureston.ca/2012/04/20/simple-work

  • I can't charge my iPhone

    I attached my iphone to a computer that had been attacked by some viruses and from then on I can't charge my iphone correctly and it everytime i want to charge it iphone shows this message after 2 or 3 minutes from plugging charger to power source.