Home » SQL & PL/SQL » SQL & PL/SQL » counting commas from numeric(amount)
counting commas from numeric(amount) [message #259998] Fri, 17 August 2007 02:17 Go to next message
ganesh_jadhav0509
Messages: 63
Registered: May 2007
Location: Chester
Member

how can i count commas(',') from selected string

eg,
select (12,12,12,213) from dual


i want to count the commas(',') from above (12,12,12,213)
the query is having 3 commas how can i count it.

Re: counting commas from numeric(amount) [message #260005 is a reply to message #259998] Fri, 17 August 2007 02:28 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
This has been asked many times before.
Check the search results for some answers.
Re: counting commas from numeric(amount) [message #260007 is a reply to message #259998] Fri, 17 August 2007 02:30 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
Edit: follow Frank's advice Wink.

MHE

[Updated on: Fri, 17 August 2007 02:31]

Report message to a moderator

Re: counting commas from numeric(amount) [message #260009 is a reply to message #259998] Fri, 17 August 2007 02:41 Go to previous messageGo to next message
vamsi kasina
Messages: 2107
Registered: October 2003
Location: Riyadh, Saudi Arabia
Senior Member
Quote:
counting commas from numeric(amount)

By the way first, you need to do an explicit conversion to character.
Then follow the search results.

By
Vamsi
Re: counting commas from numeric(amount) [message #260237 is a reply to message #259998] Fri, 17 August 2007 14:46 Go to previous message
Bill B
Messages: 1484
Registered: December 2004
Senior Member
The query

select (12,12,12,213) from dual


will fail. It is not an valid query and there is no need for the parens.

whb@xe>select (12,12,12,213) from dual
  2  /
select (12,12,12,213) from dual
          *
ERROR at line 1:
ORA-00907: missing right parenthesis


select 12,12,12,213 from dual


will return 4 different columns

and the following will return your answer.

select length('12,12,12,213') - length(replace('12,12,12,213',','))
from dual;
Previous Topic: problem with utl_smtp_data
Next Topic: how to retrieve a rollbacked data?
Goto Forum:
  


Current Time: Wed Dec 07 18:57:46 CST 2016

Total time taken to generate the page: 0.16867 seconds