i have table in want strings ab aabb aaabbb ...... n times followed b n times shown below.
eg table:
value ---------- ab aabb aaabbb aaaabbbb 1 1a abababa i want result table be:
value ---------- ab aabb aaabbb aaaabbbb i've tried this
select * [numtest] value '[a]+[b]+' but it's returning 0 rows.
can me how use special characters in sql server's like ?
here can work:
(edit - after o/p comment, commented parts not needed)
--with cte_goodvalues --( select value table1 left(value,len(value)/2) = replicate('a',len(value)/2) , right(value,len(value)/2) = replicate('b',len(value)/2) , len(value)%2=0 --) --select replicate(' ', (select max(len(value))/2 cte_goodvalues)- len(value)/2) + value --from cte_goodvalues in cte - select values have left half a-s , right half b-s. find max length , use replicate needed empty spaces in front
demo (after edit)
Comments
Post a Comment