Tag Info

New answers tagged


If you want the longest substring that means there is no other which is longer. A NOT EXISTS predicate will give this. select <whatever> from <your table> as aa where <predicates> and not exists ( select 1 from <your table> as bb where <predicates> and len(bb.SomeColumn) > len(aa.SomeColumn) ); ...


The only viable solution I could find was to write a function: FUNCTION get_noun_inflection( p_noun text, ... params ... ) -- ... body, declare, variable, etc. SELECT CASE -- ... conditions ... THEN trim( TRAILING ni.label_singular FROM p_noun ) || ni.label_plural -- Noun in singular form (no pluralization) ELSE p_noun ...


What is wrong with the (maybe too obvious?): select * from noun n, noun_inflection ni where n.label = 'handlebar' and n.label ilike '%'||ni.label_singular order by char_length(ni.label_singular) DESC limit 1;

Top 50 recent answers are included