Created
February 3, 2020 22:31
-
-
Save gavilanch/2f779fba3a854d38a37a5d7cae6ca06f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Select *, stuff(rango, 1, PATINDEX('%[0-9]%',Rango)-1, '') as Rango_Bonito | |
from Prueba p | |
INNER JOIN | |
( | |
Select IdCliente, | |
MAX(CAST(SUBSTRING(stuff(rango, 1, PATINDEX('%[0-9]%',Rango)-1, ''), 0, PATINDEX('%[^0-9]%', stuff(rango, 1, PATINDEX('%[0-9]%',Rango)-1, ''))) AS INT)) as algo3 | |
from Prueba | |
GROUP BY IdCliente | |
) t | |
on p.IdCliente = t.IdCliente and p.Rango like '%' + cast(t.algo3 as nvarchar) + '%' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment