Re: Re: getting max and min

2006-10-20 Thread James Bennett
On 10/20/06, DavidA <[EMAIL PROTECTED]> wrote: > I'm curious how you would solve this problem using SQLAlchemy. I have > _many_ needs for aggregation, subselects, and other things that are not > easy or possible to do in Django's ORM, but I've never seen an ORM that > does this (without just

Re: getting max and min

2006-10-20 Thread DavidA
Frankie Robertson wrote: > Yes, dropping down is a good thing. You'll never be able to do > everything with django's simple ORM. Raw SQL is a 'good thing', > honest. Once we get SQLAlchemy we can drop to that some of the time > but until then SQL is the way forward. Slightly OT, but... I'm

Re: getting max and min

2006-10-20 Thread zenx
thank you all! I will do it with raw SQL . thanks for the code. I hope SQLAlchemy will be implemented soon in django. thank you! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this

Re: getting max and min

2006-10-20 Thread Frankie Robertson
On 20/10/06, DavidA <[EMAIL PROTECTED]> wrote: > > > Russell Keith-Magee wrote: > > On 10/19/06, zenx <[EMAIL PROTECTED]> wrote: > > > > > > I want to get the maximum and the minimum values of various numbers. Is > > > the following method the best way to do it? > > > > The most efficient way

Re: getting max and min

2006-10-19 Thread DavidA
Russell Keith-Magee wrote: > On 10/19/06, zenx <[EMAIL PROTECTED]> wrote: > > > > I want to get the maximum and the minimum values of various numbers. Is > > the following method the best way to do it? > > The most efficient way would be to use SQL; this way, the min and max > would fall out as

Re: getting max and min

2006-10-19 Thread Russell Keith-Magee
On 10/19/06, zenx <[EMAIL PROTECTED]> wrote: > > I want to get the maximum and the minimum values of various numbers. Is > the following method the best way to do it? The most efficient way would be to use SQL; this way, the min and max would fall out as the result of a single query.

Re: getting max and min

2006-10-19 Thread sago
zenx wrote: > hi, > > just tried this but doesn't work: > > q = ArtistaTag.objects.all() > nums=[''] > for tag in q: > num = tag.artista_set.count() > nums.append(num) > > max_art = max(nums) > min_art = min(nums) > > i get a TypeError unsupported operand type(s) for -:

Re: getting max and min

2006-10-19 Thread Don Arbow
On Oct 19, 2006, at 3:21 PM, zenx wrote: > > hi, > > just tried this but doesn't work: > > q = ArtistaTag.objects.all() > nums=[''] > for tag in q: > num = tag.artista_set.count() > nums.append(num) > > max_art = max(nums) > min_art = min(nums) > > i get a TypeError

Re: getting max and min

2006-10-19 Thread zenx
hi, just tried this but doesn't work: q = ArtistaTag.objects.all() nums=[''] for tag in q: num = tag.artista_set.count() nums.append(num) max_art = max(nums) min_art = min(nums) i get a TypeError unsupported operand type(s) for -: 'str' and 'long' :(

Re: getting max and min

2006-10-19 Thread Don Arbow
On Oct 19, 2006, at 5:03 AM, zenx wrote: > > I want to get the maximum and the minimum values of various > numbers. Is > the following method the best way to do it? Python already has min and max functions available. Just feed as many values in a tuple and it will return the min or max

getting max and min

2006-10-19 Thread zenx
I want to get the maximum and the minimum values of various numbers. Is the following method the best way to do it? for tag in q: num = tag.artista_set.count() if num_ant: if num < num_ant: min_art = num else: