473,656 Members | 2,871 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(Nam e))...

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 1590
RP

"Marek Kotowski" <Ma************ @wsip.com.pl> schreef in bericht
news:e5******** *************** **@posting.goog le.com...
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(Nam e))...

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.goog le.com...
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(Nam e))...

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.goog le.com...
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(Nam e))...

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
5879
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 records with a given foreign-key value, essentially: Create table table1 { fk_id number, seq_id number
6
9986
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) from dbo.foo f where f.p = t.y ) FROM dbo.test t
1
1387
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 1/1/2004 4000.00 40.00 4040.00 1/2/2004 1000.00 10.00 1010.00 1/2/2204 2000.00 20.00 2020.00 1/3/2004 1500.00 15.00 1515.00 I want my resultant DataTable to show in DataGrid as
2
7044
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 MEDIAN(COLUMN_NAME) type function or a more general function like a 10% percentile function with syntax such as PERCENTILE(COLUMN_NAME,25). Regards JC......
1
2252
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 3 6 9 I need to determine the mean of all results for each LotID, so used the Row Average function described on the Microsoft Knowledge base, which gives
10
11925
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 post) *I'm running a total query, of the form
5
3706
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 in MySQL 4.x) Particularly, I find GROUP_CONCAT practical to quickly display 1-many
3
4589
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 in one-to-many relation. I don't need to see all values in B that relate to the particular record in A, just one value in each field in B, preferably the last entered. This is to ease a person that need to manually fix and encode
8
3125
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 custom aggregate functions in DB2, written close to three years ago by Knut Stolze: http://www-128.ibm.com/developerworks/db2/library/techarticle/0309stolze/0309stolze.html Mr. Stolze says in the first article that "urrently, there is no
22
12463
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=" & msDbFilename moConn.Properties("Persist Security Info") = False moConn.ConnectionString = msConnString moConn.CursorLocation = adUseClient moConn.Mode = adModeReadWrite' or using default...same result
0
8382
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8816
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8717
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8600
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5629
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1930
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1600
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.