To count number of occurances of a char in a very large string

Hi All,
I like to count the no of occurances of a char in a a very large string.
for example
char ch - 'c'
string str - "practical example is always needed"
c occured 2 times in the above string.
Thanks,
J.Kathir

> string str - "practical example is always needed"
Try to finish this:
        String str = "practical example is always needed";
        char search = 'c';
        int occurrence = 0;
        for(int i = 0; i < str.length(); i++) {
            // Use a method from the String-class to get a
            // char from a specific location in the String.
            // See: http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html
        System.out.println("Occerrence of char "+search+" in \""+str+"\" is: "+occurrence);

Similar Messages

  • Counting number of occurances

    I have an array of queues,
    eg:
    1, 2 ,3
    4, 5 , 6
    1, 8, 9
    2, 4, 5
    so everytime i poll each queue I get the value of the first column. I need to count the occurances of each value. Eg for this example, 1 appear twice, 4 appear once and 2 appear once. How can I do this efficiently since I may have to fetch up to 1000 queue records?
    Thanks.

    Don't ask for much do ya!
    private int occurances[9];
    //the above array holds a value for each number up to the
    //maximum number we are looking for (presumed to be 9).
    //the array will hold an int representing how many times each
    //value has been found in a queue.
    constructor { //rename this so it is a proper constructor.
        for (int i = 0; i < occurances.length; i++) {
             occurances[i] = 0; //initialise all values of the array to zero.
    public void analyseQueue(ArrayList queue[])
        for (int i = 0; i < queue.length; i++) { //for each queue:
            ArrayList currentQ = queue; //extract the queue
    for (int n = 0; n < currentQ.size(); n++) { //for each element in the queue:
    int n = (int) currentQ.get(n); //extract the integer value of the element.
    occurances[n - 1]++; //as this number has been found, increase the
    //number of occurances of it. Note the -1 as an array is zero indexed.
    public int getOccurances(int n) {
    return occurances[n - 1]; //again, because zero indexed.

  • Udf to count the number of occurances

    Hello All
    I am trying to write an UDF which can count the number of occurances of charecter ' in a string and fives the result as number of occurances - 3 . For example if the char ' is present 20 times in a string , I want the result to be 17.
    Could you help me in creating this UDF please, I am a beginner to Java.
    Thank you

    Hi Sreeni ,
    I tried you code , but it has some compilation errors ,
    The cod ei used is
      //write your code here
    int count = 0;
    String str;
    for(int i=0; i=input.strlength();i++)
    if (input = '\'')
    count = count + 1;
    count = count - 3;
    str = integer.toString(count);
    return str;
    Just as you suggested ,
    for it I got these errors
    incompatible types
    found : int required: boolean
    for(int i=0; i=input.str.length();i++)
    cannot resolve symbol
    symbol : variable str
    location: class java.lang.String
    for(int i=0; i=input.str.length();i++)
    incompatible types
    found : java.lang.String
    required: boolean if (input = '\'')
    cannot resolve symbol
    symbol : variable integer
    location: class com.sap.xi.tf._MMPOFileToPayload_
    str = integer.toString(count);
    cheers

  • Counting Number of calls Occurring at the same time (Concurrent)

    Hi All,
    Thanks for the help in advance.  I have a T-SQL problem I’m not sure how to solve.  I have a table which holds calls.  The table gives a start time and a booked duration time which I can use to create a booked end time.
    I would like to count the number of concurrent number of calls in 15 minute periods for a specific date range.  In other words – I could like to count the number of calls which are scheduled to occur at the same 15 minute time periods.
    To obtain the 15 minute periods I can join to a table we have specifically for this (a time look up table) so I the Call Start and Call End to the nearest 15 min slot.
    The base data looks like this (CallID is unique):
    I would like the results set to give a list of 15 min time periods (in DATETIME) with a count of Calls occurring in the time period.
    Here's a mockup in Excel:
    Can anyone give a good solution.  I suspect a CTE would be used – but I’m not sure how.
    Many Thanks,
    UnoT

    Try this on:
    DECLARE @CallsSample TABLE (CallID bigint NOT NULL, call_datetime smalldatetime NOT NULL, booked_duration int NOT NULL, BookedCallEnd smalldatetime NULL, Start_Qtr_Hr_15_Min time(7) NOT NULL, End_Qtr_Hr_15_Min time(7) NOT NULL)
    INSERT @CallsSample (CallID, call_datetime, booked_duration, BookedCallEnd, Start_Qtr_Hr_15_Min, End_Qtr_Hr_15_Min) VALUES
    (3487817, CAST(0xA460001E AS SmallDateTime), 90, CAST(0xA4600078 AS SmallDateTime), CAST(0x070034E230040000 AS Time), CAST(0x0700D088C3100000 AS Time)),(6177710, CAST(0xA460003C AS SmallDateTime), 115, CAST(0xA46000AF AS SmallDateTime), CAST(0x070068C461080000 AS Time), CAST(0x07001EDC0C170000 AS Time)),(4059343, CAST(0xA460004B AS SmallDateTime), 60, CAST(0xA4600087 AS SmallDateTime), CAST(0x070082357A0A0000 AS Time), CAST(0x0700EAF9DB120000 AS Time)),(60817427, CAST(0xA4600087 AS SmallDateTime), 30, CAST(0xA46000A5 AS SmallDateTime), CAST(0x0700EAF9DB120000 AS Time), CAST(0x07001EDC0C170000 AS Time)),(6689941, CAST(0xA4600096 AS SmallDateTime), 60, CAST(0xA46000D2 AS SmallDateTime), CAST(0x0700046BF4140000 AS Time), CAST(0x07006C2F561D0000 AS Time)),(10587832, CAST(0xA4600096 AS SmallDateTime), 60, CAST(0xA46000D2 AS SmallDateTime), CAST(0x0700046BF4140000 AS Time), CAST(0x07006C2F561D0000 AS Time)),(1775751, CAST(0xA46000F0 AS SmallDateTime), 720, CAST(0xA46003C0 AS SmallDateTime), CAST(0x0700A01187210000 AS Time), CAST(0x070080461C860000 AS Time)),(4492298, CAST(0xA46000F0 AS SmallDateTime), 30, CAST(0xA460010E AS SmallDateTime), CAST(0x0700A01187210000 AS Time), CAST(0x0700D4F3B7250000 AS Time)),(10033683, CAST(0xA4600104 AS SmallDateTime), 45, CAST(0xA4600131 AS SmallDateTime), CAST(0x0700BA829F230000 AS Time), CAST(0x070008D6E8290000 AS Time)),(3073339, CAST(0xA460012C AS SmallDateTime), 0, CAST(0xA460012C AS SmallDateTime), CAST(0x070008D6E8290000 AS Time), CAST(0x070008D6E8290000 AS Time)),(11211077, CAST(0xA460014A AS SmallDateTime), 30, CAST(0xA4600168 AS SmallDateTime), CAST(0x07003CB8192E0000 AS Time), CAST(0x0700709A4A320000 AS Time)),(95075608, CAST(0xA4600168 AS SmallDateTime), 20, CAST(0xA460017C AS SmallDateTime), CAST(0x0700709A4A320000 AS Time), CAST(0x07008A0B63340000 AS Time)),(10569182, CAST(0xA4600168 AS SmallDateTime), 60, CAST(0xA46001A4 AS SmallDateTime), CAST(0x0700709A4A320000 AS Time), CAST(0x0700D85EAC3A0000 AS Time)),(87260179, CAST(0xA4600168 AS SmallDateTime), 60, CAST(0xA46001A4 AS SmallDateTime), CAST(0x0700709A4A320000 AS Time), CAST(0x0700D85EAC3A0000 AS Time)),(60818683, CAST(0xA4600177 AS SmallDateTime), 30, CAST(0xA4600195 AS SmallDateTime), CAST(0x07008A0B63340000 AS Time), CAST(0x0700BEED93380000 AS Time)),(10366434, CAST(0xA460017C AS SmallDateTime), 5, CAST(0xA4600181 AS SmallDateTime), CAST(0x07008A0B63340000 AS Time), CAST(0x07008A0B63340000 AS Time)),(57064108, CAST(0xA460019F AS SmallDateTime), 45, CAST(0xA46001CC AS SmallDateTime), CAST(0x0700BEED93380000 AS Time), CAST(0x07000C41DD3E0000 AS Time)),(2257193, CAST(0xA46001A4 AS SmallDateTime), 180, CAST(0xA4600258 AS SmallDateTime), CAST(0x0700D85EAC3A0000 AS Time), CAST(0x070010ACD1530000 AS Time)),(3842940, CAST(0xA46001A4 AS SmallDateTime), 90, CAST(0xA46001FE AS SmallDateTime), CAST(0x0700D85EAC3A0000 AS Time), CAST(0x070074053F470000 AS Time)),(4407600, CAST(0xA46001A4 AS SmallDateTime), 60, CAST(0xA46001E0 AS SmallDateTime), CAST(0x0700D85EAC3A0000 AS Time), CAST(0x070040230E430000 AS Time)),(6815326, CAST(0xA46001A4 AS SmallDateTime), 90, CAST(0xA46001FE AS SmallDateTime), CAST(0x0700D85EAC3A0000 AS Time), CAST(0x070074053F470000 AS Time)),(6977921, CAST(0xA46001A4 AS SmallDateTime), 45, CAST(0xA46001D1 AS SmallDateTime), CAST(0x0700D85EAC3A0000 AS Time), CAST(0x070026B2F5400000 AS Time)),(8265287, CAST(0xA46001A4 AS SmallDateTime), 150, CAST(0xA460023A AS SmallDateTime), CAST(0x0700D85EAC3A0000 AS Time), CAST(0x0700DCC9A04F0000 AS Time)),(51019423, CAST(0xA46001A4 AS SmallDateTime), 12, CAST(0xA46001B0 AS SmallDateTime), CAST(0x0700D85EAC3A0000 AS Time), CAST(0x0700D85EAC3A0000 AS Time)),(53753674, CAST(0xA46001A4 AS SmallDateTime), 60, CAST(0xA46001E0 AS SmallDateTime), CAST(0x0700D85EAC3A0000 AS Time), CAST(0x070040230E430000 AS Time)),(55205083, CAST(0xA46001A4 AS SmallDateTime), 60, CAST(0xA46001E0 AS SmallDateTime), CAST(0x0700D85EAC3A0000 AS Time), CAST(0x070040230E430000 AS Time)),(70980359, CAST(0xA46001A4 AS SmallDateTime), 60, CAST(0xA46001E0 AS SmallDateTime), CAST(0x0700D85EAC3A0000 AS Time), CAST(0x070040230E430000 AS Time)),(79589562, CAST(0xA46001A4 AS SmallDateTime), 60, CAST(0xA46001E0 AS SmallDateTime), CAST(0x0700D85EAC3A0000 AS Time), CAST(0x070040230E430000 AS Time)),(84884442, CAST(0xA46001A4 AS SmallDateTime), 120, CAST(0xA460021C AS SmallDateTime), CAST(0x0700D85EAC3A0000 AS Time), CAST(0x0700A8E76F4B0000 AS Time)),(34352531, CAST(0xA46001AE AS SmallDateTime), 30, CAST(0xA46001CC AS SmallDateTime), CAST(0x0700D85EAC3A0000 AS Time), CAST(0x07000C41DD3E0000 AS Time)),(51675477, CAST(0xA46001B3 AS SmallDateTime), 60, CAST(0xA46001EF AS SmallDateTime), CAST(0x0700F2CFC43C0000 AS Time), CAST(0x07005A9426450000 AS Time)),(57128114, CAST(0xA46001B3 AS SmallDateTime), 45, CAST(0xA46001E0 AS SmallDateTime), CAST(0x0700F2CFC43C0000 AS Time), CAST(0x070040230E430000 AS Time)),(60819106, CAST(0xA46001B3 AS SmallDateTime), 30, CAST(0xA46001D1 AS SmallDateTime), CAST(0x0700F2CFC43C0000 AS Time), CAST(0x070026B2F5400000 AS Time)),(62155430, CAST(0xA46001B3 AS SmallDateTime), 44, CAST(0xA46001DF AS SmallDateTime), CAST(0x0700F2CFC43C0000 AS Time), CAST(0x070026B2F5400000 AS Time)),(25999755, CAST(0xA46001B8 AS SmallDateTime), 125, CAST(0xA4600235 AS SmallDateTime), CAST(0x0700F2CFC43C0000 AS Time), CAST(0x0700C258884D0000 AS Time)),(26122354, CAST(0xA46001B8 AS SmallDateTime), 125, CAST(0xA4600235 AS SmallDateTime), CAST(0x0700F2CFC43C0000 AS Time), CAST(0x0700C258884D0000 AS Time)),(27954520, CAST(0xA46001B8 AS SmallDateTime), 125, CAST(0xA4600235 AS SmallDateTime), CAST(0x0700F2CFC43C0000 AS Time), CAST(0x0700C258884D0000 AS Time)),
    (96547161, CAST(0xA46001C2 AS SmallDateTime), 60, CAST(0xA46001FE AS SmallDateTime), CAST(0x07000C41DD3E0000 AS Time), CAST(0x070074053F470000 AS Time)),(1288784, CAST(0xA46001C2 AS SmallDateTime), 90, CAST(0xA460021C AS SmallDateTime), CAST(0x07000C41DD3E0000 AS Time), CAST(0x0700A8E76F4B0000 AS Time)),(6852900, CAST(0xA46001C2 AS SmallDateTime), 60, CAST(0xA46001FE AS SmallDateTime), CAST(0x07000C41DD3E0000 AS Time), CAST(0x070074053F470000 AS Time)),(8159548, CAST(0xA46001C2 AS SmallDateTime), 90, CAST(0xA460021C AS SmallDateTime), CAST(0x07000C41DD3E0000 AS Time), CAST(0x0700A8E76F4B0000 AS Time)),(10490505, CAST(0xA46001C2 AS SmallDateTime), 90, CAST(0xA460021C AS SmallDateTime), CAST(0x07000C41DD3E0000 AS Time), CAST(0x0700A8E76F4B0000 AS Time)),(11106751, CAST(0xA46001C2 AS SmallDateTime), 15, CAST(0xA46001D1 AS SmallDateTime), CAST(0x07000C41DD3E0000 AS Time), CAST(0x070026B2F5400000 AS Time)),(32223105, CAST(0xA46001C2 AS SmallDateTime), 60, CAST(0xA46001FE AS SmallDateTime), CAST(0x07000C41DD3E0000 AS Time), CAST(0x070074053F470000 AS Time)),(8798082, CAST(0xA46001C2 AS SmallDateTime), 60, CAST(0xA46001FE AS SmallDateTime), CAST(0x07000C41DD3E0000 AS Time), CAST(0x070074053F470000 AS Time)),(20803494, CAST(0xA46001C2 AS SmallDateTime), 300, CAST(0xA46002EE AS SmallDateTime), CAST(0x07000C41DD3E0000 AS Time), CAST(0x07001417C6680000 AS Time)),(10586951, CAST(0xA46001D1 AS SmallDateTime), 60, CAST(0xA460020D AS SmallDateTime), CAST(0x070026B2F5400000 AS Time), CAST(0x07008E7657490000 AS Time)),(94186519, CAST(0xA46001E0 AS SmallDateTime), 120, CAST(0xA4600258 AS SmallDateTime), CAST(0x070040230E430000 AS Time), CAST(0x070010ACD1530000 AS Time)),(98317405, CAST(0xA46001E0 AS SmallDateTime), 60, CAST(0xA460021C AS SmallDateTime), CAST(0x070040230E430000 AS Time), CAST(0x0700A8E76F4B0000 AS Time)),(98683578, CAST(0xA46001E0 AS SmallDateTime), 45, CAST(0xA460020D AS SmallDateTime), CAST(0x070040230E430000 AS Time), CAST(0x07008E7657490000 AS Time)),(99071917, CAST(0xA46001E0 AS SmallDateTime), 30, CAST(0xA46001FE AS SmallDateTime), CAST(0x070040230E430000 AS Time), CAST(0x070074053F470000 AS Time)),(2740737, CAST(0xA46001E0 AS SmallDateTime), 60, CAST(0xA460021C AS SmallDateTime), CAST(0x070040230E430000 AS Time), CAST(0x0700A8E76F4B0000 AS Time)),(4384114, CAST(0xA46001E0 AS SmallDateTime), 60, CAST(0xA460021C AS SmallDateTime), CAST(0x070040230E430000 AS Time), CAST(0x0700A8E76F4B0000 AS Time)),(7996107, CAST(0xA46001E0 AS SmallDateTime), 60, CAST(0xA460021C AS SmallDateTime), CAST(0x070040230E430000 AS Time), CAST(0x0700A8E76F4B0000 AS Time)),(8294223, CAST(0xA46001E0 AS SmallDateTime), 90, CAST(0xA460023A AS SmallDateTime), CAST(0x070040230E430000 AS Time), CAST(0x0700DCC9A04F0000 AS Time)),(9164073, CAST(0xA46001E0 AS SmallDateTime), 90, CAST(0xA460023A AS SmallDateTime), CAST(0x070040230E430000 AS Time), CAST(0x0700DCC9A04F0000 AS Time)),(9443787, CAST(0xA46001E0 AS SmallDateTime), 480, CAST(0xA46003C0 AS SmallDateTime), CAST(0x070040230E430000 AS Time), CAST(0x070080461C860000 AS Time)),(9921813, CAST(0xA46001E0 AS SmallDateTime), 60, CAST(0xA460021C AS SmallDateTime), CAST(0x070040230E430000 AS Time), CAST(0x0700A8E76F4B0000 AS Time)),(10449493, CAST(0xA46001E0 AS SmallDateTime), 60, CAST(0xA460021C AS SmallDateTime), CAST(0x070040230E430000 AS Time), CAST(0x0700A8E76F4B0000 AS Time)),(10450055, CAST(0xA46001E0 AS SmallDateTime), 60, CAST(0xA460021C AS SmallDateTime), CAST(0x070040230E430000 AS Time), CAST(0x0700A8E76F4B0000 AS Time)),(10450221, CAST(0xA46001E0 AS SmallDateTime), 60, CAST(0xA460021C AS SmallDateTime), CAST(0x070040230E430000 AS Time), CAST(0x0700A8E76F4B0000 AS Time)),(10450559, CAST(0xA46001E0 AS SmallDateTime), 60, CAST(0xA460021C AS SmallDateTime), CAST(0x070040230E430000 AS Time), CAST(0x0700A8E76F4B0000 AS Time)),(10450836, CAST(0xA46001E0 AS SmallDateTime), 60, CAST(0xA460021C AS SmallDateTime), CAST(0x070040230E430000 AS Time), CAST(0x0700A8E76F4B0000 AS Time)),(10451107, CAST(0xA46001E0 AS SmallDateTime), 60, CAST(0xA460021C AS SmallDateTime), CAST(0x070040230E430000 AS Time), CAST(0x0700A8E76F4B0000 AS Time)),(10451347, CAST(0xA46001E0 AS SmallDateTime), 60, CAST(0xA460021C AS SmallDateTime), CAST(0x070040230E430000 AS Time), CAST(0x0700A8E76F4B0000 AS Time)),(10451597, CAST(0xA46001E0 AS SmallDateTime), 60, CAST(0xA460021C AS SmallDateTime), CAST(0x070040230E430000 AS Time), CAST(0x0700A8E76F4B0000 AS Time)),(10689864, CAST(0xA46001E0 AS SmallDateTime), 60, CAST(0xA460021C AS SmallDateTime), CAST(0x070040230E430000 AS Time), CAST(0x0700A8E76F4B0000 AS Time)),(11334051, CAST(0xA46001E0 AS SmallDateTime), 60, CAST(0xA460021C AS SmallDateTime), CAST(0x070040230E430000 AS Time), CAST(0x0700A8E76F4B0000 AS Time)),(11364433, CAST(0xA46001E0 AS SmallDateTime), 60, CAST(0xA460021C AS SmallDateTime), CAST(0x070040230E430000 AS Time), CAST(0x0700A8E76F4B0000 AS Time)),(45101155, CAST(0xA46001E0 AS SmallDateTime), 60, CAST(0xA460021C AS SmallDateTime), CAST(0x070040230E430000 AS Time), CAST(0x0700A8E76F4B0000 AS Time)),(59007149, CAST(0xA46001E0 AS SmallDateTime), 30, CAST(0xA46001FE AS SmallDateTime), CAST(0x070040230E430000 AS Time), CAST(0x070074053F470000 AS Time)),(61545449, CAST(0xA46001E0 AS SmallDateTime), 60, CAST(0xA460021C AS SmallDateTime), CAST(0x070040230E430000 AS Time), CAST(0x0700A8E76F4B0000 AS Time)),(85739178, CAST(0xA46001E0 AS SmallDateTime), 60, CAST(0xA460021C AS SmallDateTime), CAST(0x070040230E430000 AS Time), CAST(0x0700A8E76F4B0000 AS Time)),(1494995, CAST(0xA46001EF AS SmallDateTime), 30, CAST(0xA460020D AS SmallDateTime), CAST(0x07005A9426450000 AS Time), CAST(0x07008E7657490000 AS Time)),
    (4573716, CAST(0xA46001EF AS SmallDateTime), 5, CAST(0xA46001F4 AS SmallDateTime), CAST(0x07005A9426450000 AS Time), CAST(0x07005A9426450000 AS Time)),(10517748, CAST(0xA46001EF AS SmallDateTime), 10, CAST(0xA46001F9 AS SmallDateTime), CAST(0x07005A9426450000 AS Time), CAST(0x07005A9426450000 AS Time)),(11319350, CAST(0xA46001EF AS SmallDateTime), 60, CAST(0xA460022B AS SmallDateTime), CAST(0x07005A9426450000 AS Time), CAST(0x0700C258884D0000 AS Time)),(60819508, CAST(0xA46001EF AS SmallDateTime), 30, CAST(0xA460020D AS SmallDateTime), CAST(0x07005A9426450000 AS Time), CAST(0x07008E7657490000 AS Time)),(80192111, CAST(0xA46001EF AS SmallDateTime), 60, CAST(0xA460022B AS SmallDateTime), CAST(0x07005A9426450000 AS Time), CAST(0x0700C258884D0000 AS Time)),(63151763, CAST(0xA46001F4 AS SmallDateTime), 720, CAST(0xA46004C4 AS SmallDateTime), CAST(0x07005A9426450000 AS Time), CAST(0x07003AC9BBA90000 AS Time)),(97681254, CAST(0xA46001FE AS SmallDateTime), 30, CAST(0xA460021C AS SmallDateTime), CAST(0x070074053F470000 AS Time), CAST(0x0700A8E76F4B0000 AS Time)),(1279946, CAST(0xA46001FE AS SmallDateTime), 90, CAST(0xA4600258 AS SmallDateTime), CAST(0x070074053F470000 AS Time), CAST(0x070010ACD1530000 AS Time)),(2451549, CAST(0xA46001FE AS SmallDateTime), 30, CAST(0xA460021C AS SmallDateTime), CAST(0x070074053F470000 AS Time), CAST(0x0700A8E76F4B0000 AS Time)),(2992861, CAST(0xA46001FE AS SmallDateTime), 30, CAST(0xA460021C AS SmallDateTime), CAST(0x070074053F470000 AS Time), CAST(0x0700A8E76F4B0000 AS Time)),(23975539, CAST(0xA46001FE AS SmallDateTime), 30, CAST(0xA460021C AS SmallDateTime), CAST(0x070074053F470000 AS Time), CAST(0x0700A8E76F4B0000 AS Time)),(7116577, CAST(0xA46001FE AS SmallDateTime), 90, CAST(0xA4600258 AS SmallDateTime), CAST(0x070074053F470000 AS Time), CAST(0x070010ACD1530000 AS Time)),(9151341, CAST(0xA46001FE AS SmallDateTime), 60, CAST(0xA460023A AS SmallDateTime), CAST(0x070074053F470000 AS Time), CAST(0x0700DCC9A04F0000 AS Time)),(9190403, CAST(0xA46001FE AS SmallDateTime), 60, CAST(0xA460023A AS SmallDateTime), CAST(0x070074053F470000 AS Time), CAST(0x0700DCC9A04F0000 AS Time)),(9535042, CAST(0xA46001FE AS SmallDateTime), 60, CAST(0xA460023A AS SmallDateTime), CAST(0x070074053F470000 AS Time), CAST(0x0700DCC9A04F0000 AS Time)),(9919911, CAST(0xA46001FE AS SmallDateTime), 240, CAST(0xA46002EE AS SmallDateTime), CAST(0x070074053F470000 AS Time), CAST(0x07001417C6680000 AS Time)),(10565039, CAST(0xA46001FE AS SmallDateTime), 60, CAST(0xA460023A AS SmallDateTime), CAST(0x070074053F470000 AS Time), CAST(0x0700DCC9A04F0000 AS Time)),(11332503, CAST(0xA46001FE AS SmallDateTime), 60, CAST(0xA460023A AS SmallDateTime), CAST(0x070074053F470000 AS Time), CAST(0x0700DCC9A04F0000 AS Time)),(11336945, CAST(0xA46001FE AS SmallDateTime), 60, CAST(0xA460023A AS SmallDateTime), CAST(0x070074053F470000 AS Time), CAST(0x0700DCC9A04F0000 AS Time)),(11340274, CAST(0xA46001FE AS SmallDateTime), 60, CAST(0xA460023A AS SmallDateTime), CAST(0x070074053F470000 AS Time), CAST(0x0700DCC9A04F0000 AS Time)),(41961532, CAST(0xA46001FE AS SmallDateTime), 60, CAST(0xA460023A AS SmallDateTime), CAST(0x070074053F470000 AS Time), CAST(0x0700DCC9A04F0000 AS Time)),(61162342, CAST(0xA46001FE AS SmallDateTime), 45, CAST(0xA460022B AS SmallDateTime), CAST(0x070074053F470000 AS Time), CAST(0x0700C258884D0000 AS Time)),(61502310, CAST(0xA46001FE AS SmallDateTime), 20, CAST(0xA4600212 AS SmallDateTime), CAST(0x070074053F470000 AS Time), CAST(0x07008E7657490000 AS Time)),(63560086, CAST(0xA46001FE AS SmallDateTime), 100, CAST(0xA4600262 AS SmallDateTime), CAST(0x070074053F470000 AS Time), CAST(0x070010ACD1530000 AS Time)),(67801679, CAST(0xA46001FE AS SmallDateTime), 60, CAST(0xA460023A AS SmallDateTime), CAST(0x070074053F470000 AS Time), CAST(0x0700DCC9A04F0000 AS Time)),(69045173, CAST(0xA46001FE AS SmallDateTime), 30, CAST(0xA460021C AS SmallDateTime), CAST(0x070074053F470000 AS Time), CAST(0x0700A8E76F4B0000 AS Time))
    DECLARE @times TABLE (start_qtr_hr_15_min TIME)INSERT INTO @times (start_qtr_hr_15_min) VALUES
    ('00:30:00.0000000'),('01:00:00.0000000'),('01:15:00.0000000'),('02:00:00.0000000'),('02:15:00.0000000'),('02:30:00.0000000'),('02:45:00.0000000'),('03:30:00.0000000'),('04:00:00.0000000'),('04:15:00.0000000'),('04:30:00.0000000'),
    ('05:00:00.0000000'),('05:30:00.0000000'),('06:00:00.0000000'),('06:15:00.0000000'),('06:45:00.0000000'),('07:00:00.0000000'),('07:15:00.0000000'),('07:30:00.0000000'),('07:45:00.0000000'),('08:00:00.0000000'),('08:15:00.0000000'),
    ('08:30:00.0000000'),('08:45:00.0000000'),('09:00:00.0000000'),('09:15:00.0000000'),('09:30:00.0000000'),('10:00:00.0000000'),('12:30:00.0000000'),('16:00:00.0000000'),('20:15:00.0000000')
    SELECT COUNT(DISTINCT c.callID), c.Start_Qtr_Hr_15_Min
    FROM @callsSample c
    INNER JOIN @times t
    ON t.start_qtr_hr_15_min BETWEEN c.Start_Qtr_Hr_15_Min AND c.End_Qtr_Hr_15_Min
    GROUP BY c.Start_Qtr_Hr_15_Min
    Don't forget to mark helpful posts, and answers. It helps others to find relevant posts to the same question.

  • Help to count number of words and time it

    Hi,
    I need help in inputting a text file using a file browser into a JTextArea and then count the number of occurance of each words in the file and display the time it takes in a JTextField.
    Right now I am able to come up with the idea of creating an Array to list all the words but I am still unable to count them. And by extending an abstract class to create the array class. Below is attached my abstract class.
    import java.io.*;
    import java.util.Observable;
    import java.util.StringTokenizer;
    public abstract class AbstractWordCounter extends Observable
         /** Amount of time required to count words in the most recently read file. */
         protected long readTime;
         /** DELIMETERS used in this WordCounter */
         protected String DELIMETERS;
         /** By default, any AbstractWordCounter will have is delimeters set to any non-letter ASCII character */
         public AbstractWordCounter()
              this.readTime = -1;
              DELIMETERS = "";
              // Add any non-letter ASCII character to the list of tokens.
              for(int i = 0; i < 256; i++)
                   if( !Character.isLetter( (char)i  ) )
                        DELIMETERS += Character.toString( (char)i);
         /** Get the delimeters used in this WordCounter */
         public String getDelimeters()
              return DELIMETERS;
         /** Change the delimeters used in this WordCounter
          * @param newDelimeters the new delimeters to be used
         public void setDelimeters(String newDelimeters)
              DELIMETERS = newDelimeters;
          *@return    The number of unique words in this WordCountItem object
         public abstract int getSize();
         /** @return  The total number of words counted by this WordCounter */
         public abstract int getTotalNumWords();
         /** Add a String to this WordCounter
          * @param s the String s is converted to lower-case.  If the lower-case String is already in the list, it's count is
          *        incremented.  Otherwise it is added to the list and its count is set to 1.
         public abstract void add(String s);
          * Get the ith WordCountItem
          *@param  i  must be between 0 and size - 1 (inclusive)
          *@return    The WordCountItem stored at the ith location
         public abstract WordCountItem getWordCountItem(int i);
          *  Clear this WordCounter.  After this method runs, this.size == 0.
         public abstract void clearCount();
         /** @return The amount of time (in milliseconds) that was required to read the most recent file */
         public long getReadTime()
              return this.readTime;
          *  Reads the file.  Converts each word in the file to lower case and adds it to this
          *  AbstractWordCounter.  The AbstractWordCounter is cleared before reading the new file.
          *  The time required to read the file and count the words is recorded.
          *@param  fileName  file to be opened.
          *@throws FileNotFoundException
         public final void readFile(String fileName) throws FileNotFoundException
              // Clear this AbstractWordCounter.  Open the file and count the words in the file.
    }Then the time I have come up so far is in the class that extends the abstract class above and the code is as:
    public long getReadTime()
              return this.readTime;
         }and I have a hard time to actually display this in a JTextField as it says non-static cannot be applied to a static content and if I change the method into static, another error of overiding the abstract occurs...
    I am totally lost for these errors. And I am still unable to create a file browser to find a file. For now I just write a complete path to open the file.
    would someone could point me the right direction for this problem... Thanks in advance

    Crosspost: http://forum.java.sun.com/thread.jsp?forum=31&thread=521763&tstart=0&trange=15

  • Method to count number of characters in a string?

    hi.
    i'm trying to write some script that will count the number of characters in a string passed into a constructor and then compare it against another value to check whether the string passed in is valid.
    something like this
    public class Stringcheck
    public static int maxStringLength;
    public static double minSize;
    public static boolean testStringLength(String x)
    // Insert method for counting number of chars in String x and name as 'int numberOfChars
    if(number of Chars <= maxStringLength )
    return true;
    else
    return false;
    can someone help me with writing this script.
    Thanks
    Richard.

    ummm, you dont need anything fancy. try:
    String test = "this is the test string";
    int length = test.length();

  • Find number of occurances of a particular character

    Hi,
    is there any keyword to determine number of times a particular character is present in the string,
    E.g. VAR1 = 'ghghj#ghjgjgh#ghjghjg#ghjg#'.
    I want to find number of occurances of # in VAR1.
    Regards,
    Raghavendra

    Hi,
           use folowing logic.
           data:begin 0f itab,
                    var1 type c,
                     var2 type c,
                     var3 type c,
                      var4 type c,
                  end of itab.
      split var1 at '#' into itab-var1 itab-var2 itab-var3 itab-var4.
        if not itab-var1 is initial.
            count = count + 1.
        endif.
           if not itab-var2is initial.
            count = count + 1.
        endif.
        if not itab-var3is initial.
            count = count + 1.
        endif.
        if not itab-var4is initial.
            count = count + 1.
        endif.
    write count.
    regards
    amole

  • Error attempting to write location redirection to web server (Windows NT error number -2147467259 occurred)

    I'm seeing an error pop up on a development server... error
    2408:
    "Error attempting to write location redirection to web server
    (Windows NT error number -2147467259 occurred)"
    Any idea what this is? I can't seem to find anything
    solid.

    I'm having the same problem but it just started.  Logged in last week from work computer running IE 8.0.8 with no problems.  Today I keep getting problem connecting to server.   Clicking on the error indicator gets me the same error.
    Message: Object expected
    Line: 5
    Char: 1963
    Code: 0
    URI: https://setup.icloud.com/ajax_sender.html
    Tried clearing browser history,cookies, etc.. nothing works.

  • Number and occurance

    I'm trying to create source code which can output as below:
    Number      Occurances
    1          3
    8 2
    20 8
    I hv no idea on how to tight the occurance of the num. Can someone direct me on how i can settle achieve this? thanks. my code as below:
    import java.util.Scanner;
    public class Testing
         public static void main (String []args)
              Scanner sc = new Scanner(System.in);
              int number;
              int [] num = new int [31];
              int count = 0;
              int i=0;
              do
                   System.out.println("Enter any number(-1 to stop) :");
                   number = sc.nextInt();
                   if ( number>=0 && number<=30)     
                        num[i] = number ;
                        count++;
              while ( number>=0 && number<=30);
              System.out.println ("Number " + "\t Occurances");
              System.out.println ( ""+num[i] + "\t\t "+count     );
    }

    I hv no idea on how to tight the occurance of the num. Can someone direct me on how i can settle achieve this? thanks. my code as below:Your original post looks like it was machine translated to English, since most humans don't mistake adjectives and verbs ('tight' and 'settle').
    "to tight the occurance" has no meaning, and trying and guess what code which doesn't work was supposed to be doing is a waste of effort.
    If you put {code} around your code, it keeps the formatting and indentation, which makes it easier to read.

  • How to count number of sales orders generated in a month in SAP SD

    Hi SD Gurus,
    I have a very strange query from client. I have to count the number of sales order created in a month for a z report. For example 30 in Jan, 25 in Feb etc. Could anyone suggest me How to count number of sales orders generated in a month in SAP SD.
    Regards
    Vinod Kumar

    Hi,
    Goto the T.Code "SE16" or "SE16n" or "SE11".
    Enter the table name as VBAK
    Enter the created on date as the starting date of the period and to date as the end date.
    Enter.
    Click on "Number of Entries".It will tell you the number of entries created in a particular period.
    If you want a report,goto the T.Code "VA05n".
    Regards,
    Krishna.

  • How to Count Number of completed line items in past 6 months / 12 months ?

    How to Count Number of completed line items in past 6 months / 12 months ?
    Hi,
    I am trying to count "Number of Completed Line Items in Purchase Order Document" for my Key Figure ZPO_CNT.
    Purchase Order document = ZEBELN
    Line Item = ZEBELP.
    I need to find and count if the Line Item has been received in the past 6 months from today and similarly in the past 12 months.
    I have "Delivery Completed" field, ELIKZ.
    So, based on this would I be able to calculate it in Query Designer?
    If so, Please let me know how

    Hello Deva
    If youe want to calculate the completed line item for last 6 or 12 month then i think u will be displaying the query data for these montrhs...create a customer exit to give you date range and restric it in filter area....
    Now Choose any of the below option
    1. I would suggest to implement an additional key figure "counter" in cube and fill values with one for which delivery is completed.
    Now use calculated key figure in Query Designer based on logic
    IF counter = 1 THEN counter ELSE 0
    OR
    2. create a formula variable based on ELIKZ and use replacement path variable, it will display you no. of docs for which delivery is completed....
    Award points if it solves your problem
    Revert back in case of further assistance...
    Thanks
    Tripple k

  • How to Count number of words in a file....

    Hi Experts,
    I have uploaded the text file, from the application server, like this: 
    call function 'GUI_UPLOAD'
      exporting
        filename = LV_ip_FILENAME
      tables
        data_tab = LT_FILETABLE.
    The text file contains some number character words....  like "sap labs india..... "
    Now, I wanted to count number of words in an internal table  LT_FILETABLE....  can anybody help me?

    Hi,
    Special Characters in Regular Expressions
    The following tables summarize the special characters in regular expressions:
    Escape character
    Special character Meaning
    Escape character for special characters
    Special character for single character strings
    Special character Meaning
    . Placeholder for any single character
    C Placeholder for any single character
    d Placeholder for any single digit
    D Placeholder for any character other than a digit
    l Placeholder for any lower-case letter
    L Placeholder for any character other than a lower-case letter
    s Placeholder for a blank character
    S Placeholder for any character other than a blank character
    u Placeholder for any upper-case letter
    U Placeholder for any character other than an upper-case letter
    w Placeholder for any alphanumeric character including _
    W Placeholder for any non-alphanumeric character except for _
    [ ] Definition of a value set for single characters
    [^ ] Negation of a value set for single characters
    [ - ] Definition of a range in a value set for single characters
    [ [:alnum:] ] Description of all alphanumeric characters in a value set
    [ [:alpha:] ] Description of all letters in a value set
    [ [:blank:] ] Description for blank characters and horizontal tabulators in a value set
    [ [:cntrl:] ] Description of all control characters in a value set
    [ [:digit:] ] Description of all digits in a value set
    [ [:graph:] ] Description of all graphic special characters in a value set
    [ [:lower:] ] Description of all lower-case letters in a value set
    [ [:print:] ] Description of all displayable characters in a value set
    [ [:punct:] ] Description of all punctuation characters in a value set
    [ [:space:] ] Description of all blank characters, tabulators, and carriage feeds in a value set
    [ [:unicode:] ] Description of all Unicode characters in a value set with a code larger than 255
    [ [:upper:] ] Description of all upper-case letters in a value set
    [ [:word:] ] Description of all alphanumeric characters in a value set, including _
    [ [:xdigit:] ] Description of all hexadecimal digits in a value set
    a f
          v Diverse platform-specific control characters
    [..] Reserved for later enhancements
    [==] Reserved for later enhancements
    u2192 More
    Special characters for character string patterns
    Special character Meaning
    Concatenation of n single characters
    {n,m} Concatenation of at least n and a maximum of m single characters
    {n,m}? Reserved for later enhancements
    ? One or no single characters
    Concatenation of any number of single characters including 'no characters'
    *? Reserved for later enhancements
    + Concatenation of any number of single characters excluding 'no characters'
    +? Reserved for later enhancements
    | Linking of two alternative expressions
    ( ) Definition of subgroups with registration
    (?: ) Definition of subgroups without registration
    1, 2, 3 ... Placeholder for the register of subgroups
    Q ... E Definition of a string of literal characters
    (? ... ) Reserved for later enhancements
    for more details please refer the following,
    [http://help.sap.com/abapdocu_70/en/ABENREGEX_SYNTAX_SIGNS.htm]
    [http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/902ce392-dfce-2d10-4ba9-b4f777843182?QuickLink=index&overridelayout=true]
    Thanks,
    Renuka S.

  • How to count number of edges using PXIe-6363 Counters

    Hello,
    I am trying to count number of edges in a test signal in a 50 ms duration. I am using PXIe-6363 card and connecting the test signal to CTR 0 SRC (PFI 8). Is it a correct connection? What else do I need hardware-wise to make a correct set up for this application?
    Thanks
    Jeet
    Solved!
    Go to Solution.

    Hi Jeet,
    When you say interrupt signal, do you mean a pulse that will pause your counter task? If that is the case, and you want to pause your task with a digital pulse, you need to use the DAQmx Trigger Property Node and set that to Pause, Trigger Type. As you said, you can connect that signal coming from the chip to any PFI line and then set that line as the source of the property node.
    There is an example that you can use that does exactly what I just described. This example is called Count Digital Events-Pause Trig.vi, and you can find it by going to Help>Find Examples..., then on the NI Example Finder window go to the Browse tab and navigate in the folders to Hardware Input and Outpout\DAQmx\Counter Measurements\Count Digital Events.
    Regards.
    Jorge
    Applications Engineer
    National Instruments
    Certified LabVIEW Associate Developer (CLAD)

  • How to count number of raw & put result top of page?

    I try to count number of table raw it work fine  but when I wont to put result top of page it dose not work
    only count one table raw
    REPORT  ZTEST.
    DATA: it_sflight TYPE TABLE OF Sflight WITH HEADER LINE  .
    DATA counter TYPE i VALUE 0.
    start-of-SELECTION.
    SELECT-OPTIONS: carID for it_sflight-carrid.
    SELECT-OPTIONS: connID for it_sflight-connid.
    SELECT * FROM Sflight INTO CORRESPONDING FIELDS OF TABLE it_sflight 
    WHERE carrid IN carID and connID IN connid.
    loop at it_sflight .
      counter = counter + 1 .
      write: /5 it_sflight-carrid,sy-vline,
               30 it_sflight-connid,sy-vline,
                  45 it_sflight-fldate,sy-vline,
                    60 it_sflight-currency,sy-vline.
    ULINE.
    endloop.
    end-of-SELECTION.
    TOP-OF-PAGE .
    *START-OF-SELECTION.
    WRITE:  'Total Rows : ', counter.
    ULINE.
    WRITE: /5 'Carrid',sy-vline,
            30 'Connid',sy-vline,
            45 'Fldate',sy-vline,
              60 'Currency',sy-vline.
    ULINE.
    how can I solve this problem ?

    Hi
    Instead of using counter in a loop use describe statement.
    Describe it_sflight.
    the no of rows will get populated in the system variable sy-tfill.
    DATA: it_sflight TYPE TABLE OF Sflight WITH HEADER LINE  .
    DATA counter TYPE i VALUE 0.
    start-of-SELECTION.
    SELECT-OPTIONS: carID for it_sflight-carrid.
    SELECT-OPTIONS: connID for it_sflight-connid.
    SELECT * FROM Sflight INTO CORRESPONDING FIELDS OF TABLE it_sflight
    WHERE carrid IN carID and connID IN connid.
    DESCRIBE TABLE it_sflight.
    loop at it_sflight .
      counter = counter + 1 .
      write: /5 it_sflight-carrid,sy-vline,
               30 it_sflight-connid,sy-vline,
                  45 it_sflight-fldate,sy-vline,
                    60 it_sflight-currency,sy-vline.
    ULINE.
    endloop.
    end-of-SELECTION.
    TOP-OF-PAGE .
    *START-OF-SELECTION.
    WRITE:  'Total Rows : ', sy-tfill.
    ULINE.
    WRITE: /5 'Carrid',sy-vline,
            30 'Connid',sy-vline,
            45 'Fldate',sy-vline,
              60 'Currency',sy-vline.
    ULINE.
    Thanks
    Rahul jain
    Edited by: Rahuljn on Feb 2, 2011 10:58 AM

  • How to count number of ones in table

    Hello,
     i created one table 16x32 each cell is updating 1 byte of data,how to count number of one in all cell,and is it right way to calculate check sum??
    thank you

    The simplest way is to call GetTableCellRangeValues with VAL_ENTIRE_TABLE as the range, next summing array elements.
    But I don't understand your comment on checksum, so this may not be the more correct method for your actual needs: can you explain what do you mean?
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

Maybe you are looking for

  • Tooltip on pushbutton on alv report selection screen

    Hi Experts, I have a selection screen with two pushbuttons i want to provide tooltip on this button when user takes his cursor on it .. some part of my code Selection screen: SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t01. SELECTION-SCR

  • How to debug a transfer rule during data load?

    I am conducting a flat file (excel sheet saved as a CSV file) data load.  The flat file contains a date field and the value is '12/18/1988'.  In transfer rule for this field, I use a function call to transfer this value to '19881218' which correspond

  • Deploying SOA components on different servers/domains

    Is it possible to disassemble components developed on the SOA/ADF suite of JDeveloper and deploy them in different domains? i.e deploy adf web application in one domain, deploy bpm in a different domain and bpel processes in a different domain? Will

  • Difference between sap xi and xMII

    Hi all,   Can any body provide the information on SAP xMII  and compare with SAP XI. Please help to find out scenario's based on the SAP XI and xMII.

  • Does LabVIEW support the SNMP (Simple Network Management Protocol)?

    I looked at LabVIEW 2014 online help for some info on SNMP. A problem was posted in 1996 and updated in 2008. Does LabVIEW Support the SNMP (Simple Network Management Protocol)? http://digital.ni.com/public.nsf/allkb/4CD3625A939A77DE852564050047D3BD