![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Is there a sql-function that counts characters in a string? I didn't find anything suitable in my ase documentation (ASE 11.9.2, linux). |
#3
| |||
| |||
|
|
datalength() is the function you're looking for. But I'd seriously question the design if you're using strings to store aggregates of discrete numeric elements. |
#4
| |||
| |||
|
|
Hi Larry, thanks for your answer! datalength() is the function you're looking for. But I'd seriously question the design if you're using strings to store aggregates of discrete numeric elements. unfortunately data_length() does not help. I neet to count the numbers of _one_ special character in a string. Sorry, if I did not describe my problem clearly enough. I need a function which returns 2 if it counts the numbers of the character "," in the string like "100, 100, 100" However, I have found a workaround. I'll use the LIKE-keyword in my where clause (WHERE string LIKE "%,%,%". So I can be sure that the query returns datasets with 2 or more "," in the string. Thanks again! Roland |
#5
| |||
| |||
|
|
*Hi NG, my problem: In a select statement I read a string from a varchar(255) column. The results may be 1.) "0, 0" 2.) "100, 200, 1" 3.) "" I want to change the strings, so that every string has a forma like: "number, number, number". The strings should look like: 1.) "0, 0, 1" (add a ', 1') 2.) "100, 200, 1" (remains unchanged) 3.) "0, 0, 1" (add a '0, 0, 1') How can I do that? My first idea was to count the comma-character. Add a "0, 0, 0" if no comma is found Add a ", 1" if one comma is found Add nothing if 2 comma were found. Is there a sql-function that counts characters in a string? I didn' find anything suitable in my ase documentation (ASE 11.9.2, linux). Any help is welcome! Thanks in advance, Roland |
#6
| |||
| |||
|
|
hi can u help me out my column contains data like firstname,lastname. i want the output to display like lastname,firstname. can u guide me for same |
|
I hope if you play with charindex and substring then you can get the result. Try it. Ram DSL "Roland Reichenberg" <r.reichenberg (AT) gmx (DOT) de> wrote Hi Larry, thanks for your answer! datalength() is the function you're looking for. But I'd seriously question the design if you're using strings to store aggregates of discrete numeric elements. unfortunately data_length() does not help. I neet to count the numbers of _one_ special character in a string. Sorry, if I did not describe my problem clearly enough. I need a function which returns 2 if it counts the numbers of the character "," in the string like "100, 100, 100" However, I have found a workaround. I'll use the LIKE-keyword in my where clause (WHERE string LIKE "%,%,%". So I can be sure that the query returns datasets with 2 or more "," in the string. Thanks again! Roland |
#7
| |||
| |||
|
|
hi can u help me out my column contains data like firstname,lastname. i want the output to display like lastname,firstname. can u guide me for same I cant understand fully... But this is my understanding.... table1... ------------------ Name ------------------ ram,mohan ram,kumar ------------------ the output u r expecting: mohan,ram kumar,ram query: select substring(charindex(Name,',')+1,data_length(Name)) +',' + substring(1,charindex(Name,',') -1) from table1 Ram DSL www.dslsoft.net reachram (AT) bharatmail (DOT) com (Ram DSL) wrote in message news:<f1565749.0402090705.702d755a (AT) posting (DOT) google.com>... I hope if you play with charindex and substring then you can get the result. Try it. Ram DSL "Roland Reichenberg" <r.reichenberg (AT) gmx (DOT) de> wrote Hi Larry, thanks for your answer! datalength() is the function you're looking for. But I'd seriously question the design if you're using strings to store aggregates of discrete numeric elements. unfortunately data_length() does not help. I neet to count the numbers of _one_ special character in a string. Sorry, if I did not describe my problem clearly enough. I need a function which returns 2 if it counts the numbers of the character "," in the string like "100, 100, 100" However, I have found a workaround. I'll use the LIKE-keyword in my where clause (WHERE string LIKE "%,%,%". So I can be sure that the query returns datasets with 2 or more "," in the string. Thanks again! Roland |
#8
| |||
| |||
|
|
Roland Reichenberg wrote: *Hi NG, my problem: In a select statement I read a string from a varchar(255) column. The results may be 1.) "0, 0" 2.) "100, 200, 1" 3.) "" I want to change the strings, so that every string has a format like: "number, number, number". The strings should look like: 1.) "0, 0, 1" (add a ', 1') 2.) "100, 200, 1" (remains unchanged) 3.) "0, 0, 1" (add a '0, 0, 1') How can I do that? My first idea was to count the comma-character. Add a "0, 0, 0" if no comma is found Add a ", 1" if one comma is found Add nothing if 2 comma were found. Is there a sql-function that counts characters in a string? I didn't find anything suitable in my ase documentation (ASE 11.9.2, linux). Any help is welcome! Thanks in advance, Roland * |
#9
| |||
| |||
|
|
Hi Roland, I have got a simple function. But it will work in 12 and above... You may try this. Ram DSL London www.dslsoft.net Roland Reichenberg wrote: *Hi NG, my problem: In a select statement I read a string from a varchar(255) column. The results may be 1.) "0, 0" 2.) "100, 200, 1" 3.) "" I want to change the strings, so that every string has a format like: "number, number, number". The strings should look like: 1.) "0, 0, 1" (add a ', 1') 2.) "100, 200, 1" (remains unchanged) 3.) "0, 0, 1" (add a '0, 0, 1') How can I do that? My first idea was to count the comma-character. Add a "0, 0, 0" if no comma is found Add a ", 1" if one comma is found Add nothing if 2 comma were found. Is there a sql-function that counts characters in a string? I didn't find anything suitable in my ase documentation (ASE 11.9.2, linux). Any help is welcome! Thanks in advance, Roland * |
![]() |
| Thread Tools | |
| Display Modes | |
| |