Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Find person with longest name
Message
From
20/03/2018 13:19:35
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01658805
Message ID:
01658862
Views:
80
>Hi: Using foxpro, I have a table as follows:
>
>ID Name
>------ --------------------
>1234 Fred
>5678 Robin
>2345 Bertha
>2345 Bertha Smith
>5678 Robin Jackson
>
>I am trying to figure out an SQL query that will identify the people with the longest names, and as a side answer: the number of rows that contain
>the same ID. Thank you, Steve
>
>This gets me into the ballpark and I suspect that foxpro can do this:
>
>SELECT r1.id, r1.name, LEN(ALLTRIM(r1.name)) as l, COUNT(r1.id) ;
>FROM aan as r1 LEFT JOIN aan as r2 on r1.id = r2.id .and.;
>LEN(ALLTRIM(r2.name)) < LEN(ALLTRIM(r1.name)) .or.;
>LEN(ALLTRIM(r1.name)) > LEN(ALLTRIM(r2.name));
>GROUP BY r1.name, r1.id
>
>But I can't figure out what count(ID) is doing, how to return the number of rows per ID, or how to limit my results
>to the rows that have the longest names?

Ever how many databases are set up to handle surnames like Wolfe­schlegel­stein­hausen­berger­dorff­welche­vor­altern­waren­gewissen­haft­schafers­wessen­schafe­waren­wohl­gepflege­und­sorg­faltig­keit­be­schutzen­vor­an­greifen­durch­ihr­raub­gierig­feinde­welche­vor­altern­zwolf­hundert­tausend­jah­res­voran­die­er­scheinen­von­der­erste­erde­mensch­der­raum­schiff­genacht­mit­tung­stein­und­sieben­iridium­elek­trisch­motors­ge­brauch­licht­als­sein­ur­sprung­von­kraft­ge­start­sein­lange­fahrt­hin­zwischen­stern­artig­raum­auf­der­suchen­nach­bar­schaft­der­stern­welche­ge­habt­be­wohn­bar­planeten­kreise­drehen­sich­und­wo­hin­der­neue­rasse­von­ver­stand­ig­mensch­lich­keit­konnte­fort­pflanzen­und­sicher­freuen­an­lebens­lang­lich­freude­und­ru­he­mit­nicht­ein­furcht­vor­an­greifen­vor­anderer­intelligent­ge­schopfs­von­hin­zwischen­stern­art­ig­raum ?
( https://en.wikipedia.org/wiki/Hubert_Blaine_Wolfeschlegelsteinhausenbergerdorff,_Sr. )
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform