Page 1 of 1

How to determine a column's "largest" value?

Posted: Thu Nov 04, 2004 7:09 pm
by jkj2001
Hi all,

We're using version 4.04.1067366033 of texis here, and I was wondering how I could go about determining the largest value sitting in a given column?

For instance, say I have an Author field; I'd like to know who has the longest name and how many characters it is. Thanks!

How to determine a column's "largest" value?

Posted: Thu Nov 04, 2004 10:38 pm
by John
select max(length(Author)) from Table

will give you the length of the longest Author. That doesn't give you the name of that Author. You might also want:

select Author, length(Author) from Table order by 2 desc

will list all the authors by length of name, so if you just pluck off the first value you'll have a name.

How to determine a column's "largest" value?

Posted: Fri Nov 05, 2004 1:56 pm
by jkj2001
Thanks John!

How to determine a column's "largest" value?

Posted: Fri Nov 12, 2004 2:13 pm
by jkj2001
Hi again,

This function works great...except when I tried it on a blob field. Is there a similar method I can use to find the max length in that column?

How to determine a column's "largest" value?

Posted: Fri Nov 12, 2004 2:50 pm
by mark
Try converting it to varchar first convert(Author,'varchar')

How to determine a column's "largest" value?

Posted: Fri Nov 12, 2004 4:01 pm
by jkj2001
Thanks-- I got what I needed by running a select and ordering by length, in descending sequence.

For some reason though, when I tried using max --as in "max(length(convert(myblob,'varchar')))"-- I received an "ABEND: signal 11" error? Not sure why, it cropped up immediately after the tsql command.

How to determine a column's "largest" value?

Posted: Fri Nov 12, 2004 5:57 pm
by mark
ABEND means texis had problems handling that query. What version of texis?