Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
List longest unique string for each id
create table my_table (id varchar(4),val varchar(64)); INSERT INTO my_table VALUES('k1', NULL), ('k2', 'Other string'),('k2', 'sneak string'),('k2', NULL),('k3', 'Long string'),('k3', 'string'),('k3', 'sneaky'),('k4',''); select id,min(val) val from my_table t where len(val)=( select max(len(t2.val)) from my_table t2 where t2.id= t.id ) and len(val)>0 group by id
run
|
edit
|
history
|
help
0
2021-03-06_LeetCodeSQL
variables and table variables inside a cursor loop
CTE with recursive
Libros
EXP 8
Hack_this
SQL left join
№1
20181CSE0041
Hierarchy table to exclude root