On Mar 06, 2006, at 4:08 AM, Trausti Thor Johannsson wrote:
Hey, I know this is possible in Ansi SQL, but don't know how :oops:
Not good with sub-queries. I use RealSQL (Sqlite) and RB 2006r1 pro
I have a people database, and would like to do some statistics, like
find the most common name, least common name, and if possible find out
AVG of babies people have. The record looks like this
people:
ID int, name varchar, mother int, father int (simplified, but should
do).
mother and father link to the ID ofcourse.
Could someone help me with this SQL magic ? I know how to do this by
code, but when you have 50k+ items, that would take days for a
recursive subrutine to run (Mac Mini G4) :)
Most common name - this should do it
select name, count(name) from people group by name order by
count(name) desc limit 1
Least common name - this should do it
select name, count(name) from people group by name order by
count(name) asc limit 1
average count of children .... hmmmm that one seems to require a
recursive query
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>