469,625 Members | 1,059 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,625 developers. It's quick & easy.

Problem with aggregate functions

I have a table PUPILS with a field Name (varchar).
The problem: how to select a longest Name in the table
and its length? I mean something like this:

SELECT Name, (MAX(LENGTH(Name))...

It doesn't work, of course. I tried 'grouping by' but this also fails.

Thank you in advance.

Marek Kotowski
Warsaw
Jul 19 '05 #1
3 1489
RP

"Marek Kotowski" <Ma************@wsip.com.pl> schreef in bericht
news:e5*************************@posting.google.co m...
I have a table PUPILS with a field Name (varchar).
The problem: how to select a longest Name in the table
and its length? I mean something like this:

SELECT Name, (MAX(LENGTH(Name))...

It doesn't work, of course. I tried 'grouping by' but this also fails.

Thank you in advance.

Marek Kotowski
Warsaw


select name, length(name) as L
from table
order by L desc
limit 1;

(?)

RP
Jul 19 '05 #2
RP

"Marek Kotowski" <Ma************@wsip.com.pl> schreef in bericht
news:e5*************************@posting.google.co m...
I have a table PUPILS with a field Name (varchar).
The problem: how to select a longest Name in the table
and its length? I mean something like this:

SELECT Name, (MAX(LENGTH(Name))...

It doesn't work, of course. I tried 'grouping by' but this also fails.

Thank you in advance.

Marek Kotowski
Warsaw


select name, length(name) as L
from table
order by L desc
limit 1;

(?)

RP
Jul 19 '05 #3
RP

"Marek Kotowski" <Ma************@wsip.com.pl> schreef in bericht
news:e5*************************@posting.google.co m...
I have a table PUPILS with a field Name (varchar).
The problem: how to select a longest Name in the table
and its length? I mean something like this:

SELECT Name, (MAX(LENGTH(Name))...

It doesn't work, of course. I tried 'grouping by' but this also fails.

Thank you in advance.

Marek Kotowski
Warsaw


select name, length(name) as L
from table
order by L desc
limit 1;

(?)

RP
Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Ariel Jakobovits | last post: by
1 post views Thread by sausage31 | last post: by
5 posts views Thread by David Garamond | last post: by
8 posts views Thread by jefftyzzer | last post: by
22 posts views Thread by MP | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.