Jump to content

Helpppp Teradata experts unnara?


Recommended Posts

Posted

I need a solution to find all positions of a substring in a string that has  multiple occurrences.

 

ed., their is a soc sec  no  xxx-xx-xxxx lo '-' is in position 4 and 7. I want to get a query that determines both the positions.

Posted

@loveindia  baa basic sql logic nuvvu ivvagaligina nenu teradata eq ki marchukunta

Posted
19 minutes ago, ranku_mogudu said:

I need a solution to find all positions of a substring in a string that has  multiple occurrences.

 

ed., their is a soc sec  no  xxx-xx-xxxx lo '-' is in position 4 and 7. I want to get a query that determines both the positions.

bro try this its complicated for you i guess but its microsoft sql (google lo dorikindi) hope it helps

 

declare @name nvarchar(max)
set @name ='ali reza dar yek shabe barani ba yek  dokhtare khoshkel be disco raft va ali baraye 1 saat anja bud va sepas... ali...'

Declare @a table (pos int)
Declare @pos int
Declare @oldpos int
Select @oldpos=0
select @pos=patindex('%ali%',@name) 
while @pos > 0 and @oldpos<>@pos
 begin
   insert into @a Values (@pos)
   Select @oldpos=@pos
   select @pos=patindex('%ali%',Substring(@name,@pos + 1,len(@name))) + @pos
end

Select * from @a

Posted

select 

instr('123-45-6789', '-' , 1, LEVEL)

from DUAL

Connect by LEVEL <= REGEXP_COUNT ( '123-45-6789' , '-' )

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...