Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Test if a string can be made with substrings!
with s as( select n,s from(values(1,'Hello, world!'), (2,'la lal al '), (3,'this is a string'), (4,'thi is a string'), (5,'aaaaa'), (6,'foo bar foobar'), (7,'ababab'), (8,''))s(n,s)), l as( select n,l from(values(1,'l'),(1,'He'),(1,'o, wor'),(1,'d!'), (2,'la'),(2,' l'),(2,'al '), (3,'this should return falsy'), (4,'this'),(4,'i i'),(4,' a'),(4,' string'), (5,'aa'), (6,'foo'),(6,'bar'),(6,' '),(6,'spam'), (7,'a'),(7,'ba'),(7,'ab'), (8,'The string can be constructed with nothing!'))l(n,l)), --The solution starts from the next line. u as( select s.n, s collate Latin1_General_BIN s, l collate Latin1_General_BIN l, row_number()over(partition by l.n order by len(l)desc)r from s,l where s.n=l.n), v as( select n,s,l,replace(s,l,'')c,r from u where r=1 union all select u.n,u.s,u.l,replace(v.c,u.l,''),u.r from v,u where v.n=u.n and v.r+1=u.r ) select s,iif(min(c)='',1,0)u from v group by n,s
run
|
edit
|
history
|
help
0
Admno
QLSV
QLSV
Mywall
Select empID whose salary is greater than their managers
my sql2
tt
MSQL in 10 mn ~ Lesson 9 Performing Mathematical Calculations - orderitems ~ expanded_price
aawrish
MyDb