Quantcast
Channel: Teradata Forums - Database
Viewing all articles
Browse latest Browse all 14773

Find position of a character in a string - response (7) by CarlosAL

$
0
0

Sorry for jumping in.
You can also get the results using an 'iterator' :
As per your example (4th ocurrence of  '_':
 BTEQ -- Enter your SQL request or BTEQ command:
SELECT SUBSTR(pre.cadena, it.iterador, 1) caracter,
       it.iterador posicion
  FROM ( SELECT '1_3_5_7_9_ABCDEF' cadena ) pre,
       ( SELECT day_of_calendar iterador FROM SYS_CALENDAR.CALENDAR WHERE DAY_OF_CALENDAR < 16) it
 WHERE caracter='_'
 QUALIFY ROW_NUMBER() OVER (ORDER BY posicion) = 4
 ;

 *** Query completed. One row found. 2 columns returned.
 *** Total elapsed time was 1 second.

caracter     posicion
--------  -----------
_                   8
 
HTH.
Cheers.
Carlos.


Viewing all articles
Browse latest Browse all 14773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>