DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: Urgent

  1. #1
    Join Date
    Nov 2000
    Posts
    416

    Question

    Can you tell me how can I count number of specific character in a string? i.e. I want to count no. of ',' in this string '12.5,44.7,400.25,8.5'. Syntax please.


  2. #2
    Join Date
    Feb 2000
    Location
    Washington DC
    Posts
    1,843
    See SUBSTR builtin function syntax.
    [url]http://www.dbasupport.com/forums/showthread.php?threadid=6430[/url]
    Reddy,Sam

  3. #3
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    Well, using SUBSTR alone can hardly ever give you any usable result with this problem ;).

    TRANSLATE seems more appropriate. From your example I conclued you only have numerics, comma and decimal point and space characters in your strings. If so, you can use the following:

    SELECT LENGTH(TRIM(TRANSLATE('12.5,44.7,400.25,8.5', ',.0123456789', ','))) FROM dual;

    It will return you the number of commas in your string.
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width