473,406 Members | 2,345 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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 1581
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ariel Jakobovits | last post by:
I have a table with 2 primary keys, one is a foreign key, the other is produced by a sequence. I want to SELECT query for one record that has a list of the sequence-produced values for all...
6
by: Steven An | last post by:
Howdy, I need to write an update query with multiple aggregate functions. Here is an example: UPDATE t SET t.a = ( select avg(f.q) from dbo.foo f where f.p = t.y ), t.b = ( select sum(f.q)...
1
by: Job Lot | last post by:
Is it possible to use Aggregate functions with GROUP BY Clauses on DataTable. I have a DataTable with following values: Date Amount Int Balance 1/1/2004 5000.00 50.00 5050.00...
2
by: jc | last post by:
Hi. Just as we have AVG(COLUMN_NAME) and MAX(COLUMN_NAME) how can I write my own variation of a such a function. If I can appreciate how to do this, then I hopefully I can write a...
1
by: sausage31 | last post by:
I have a table as follows.... Device LotID Result1 Result2 Result3 aaa 1 5 10 15 bbb 1 2 4 6 aaa 2 ...
10
by: neb | last post by:
Dear member of the forum, Ms access has built-in aggregate function like: -Sum, Max, First, Avg, ... Is it possible to build user-defined aggregate? (if you have any clue, do not hesitate to...
5
by: David Garamond | last post by:
What do people think of adding some more aggregate functions. These are the ones that MySQL has and PG doesn't: - STD/STDDEV - VARIANCE - BIT_OR - BIT_AND - GROUP_CONCAT (for strings, added...
3
by: S P Arif Sahari Wibowo | last post by:
Hi! I would like to make an editable continous form, where most fields will be from table A and editable, except 1-3 fields are a glimpse into table B and uneditable. Table A relate to table B...
8
by: jefftyzzer | last post by:
The current issue of "Oracle Magazine" has an article on creating custom aggregate functions, which naturally got me thinking about how to do this in DB2. I found some articles on creating...
22
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source="...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.