Re: How to find persons who like red fruits or crunchy veggies?

From: Neo <neo55592_at_hotmail.com>
Date: 17 Nov 2006 16:10:08 -0800
Message-ID: <1163808608.165887.124060_at_f16g2000cwb.googlegroups.com>


> In your language, can you query:
> How many fruit colors are there?
> Which fruit color(s) is/are the most liked?
> How many veggies are there that nobody likes?

An updated example with min, max, sum, avg and count functions.

(; Create qty 28, 30, 35)
(new '25 'quantity)
(new '30 'quantity)
(new '35 'quantity)

(; Create a verb named age)
(new 'age 'verb)

(; Create a person named john whose age is 25)
(new 'john 'person)
(create john age 25)

(; Create a person named mary whose age is 30)
(new 'mary 'person)
(create mary age 30)

(; Create a person named bob whose age is 35)
(new 'bob 'person)
(create bob age 35)

(; Create a person named sue whose age is unknown)
(new 'sue 'person)

(; Count persons)
(; Returns qty instance named 4)
(count (select person instance *))

(; Count persons with age)
(; Returns qty instance named 3)
(count (and (select person instance *)

            (select * age)))

(; Get minimum age of persons)
(; Returns qty instance named 25)
(min (select (select person instance *) age *))

(; Get maximum age of persons)
(; Returns qty instance named 35)
(max (select (select person instance *) age *))

(; Get sum of persons age)
(; Returns qty instance named 90)
(sum (select (select person instance *) age *))

(; Get average of persons age)
(; Returns qty instance named 30)
(avg (select (select person instance *) age *))

For details, see www.dbfordummies.com/example/ex045.asp Received on Sat Nov 18 2006 - 01:10:08 CET

Original text of this message