Forums / Developer / grouping by an attribute

grouping by an attribute

Author Message

Pablo C. Vergara Castro

Wednesday 18 August 2004 12:05:00 am

Hi to all.

I would like to know the way to make fetch that single gives back objects to me grouped by a certain attribute. For example, I have several objects of a class publication that have an attribute dates, and what I want it is to know the way to extract the dates that are different and in addition to solely be able to count them.

{... 1999 ...},{... 2000 ...},{... 1999 ...},{... 2001 ...},{... 2000 ...} ===> {1999},{2000},{2001}, (3 attributes)

Eirik Alfstad Johansen

Wednesday 18 August 2004 6:54:47 am

Hi Pablo,

I would love to try and help you, but I can't understand what you're trying to do. Could you try to elaborate?

Thanks in advance !

Sincerely,

Eirik Johansen
http://www.netmaking.no/

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Pablo C. Vergara Castro

Wednesday 18 August 2004 7:30:06 am

I think that nobody help me because they did not understand my poor English :-(.

What I need to obtain is a query that return the data of diverse objects, but grouped (like group by of SQL) by a certain attribute, this attribute is of text type but store years.

I will develop a little plus the example that I exposed:

Imagine you a set of objects of a certain class that have an attribute of type text which we used to store a year:

Name: Paul
Second_Name:Kristoff
Birth_Year: 1945

Name: Appel
Second_Name:Jobs
Birth_Year: 1955

Name: Sara
Second_Name:Barrer
Birth_Year: 1945

Name: Stephen
Second_Name:Jobs
Birth_Year: 1955

Name: John
Second_Name: John
Birth_Year: 1978

Now I want to obtain by means of fetch (or two)

a) Objects that have the attribute different year.
b) the number of objects that there are with the different year.

Following the example:

a)
Year: 1945
Year: 1955
Year: 1978

b) 3