Re: group by "project"

2023-05-24 Thread 'Mohamed Yahiya Shajahan' via Django users
[ { "project": 1, "date": "2023-05-22", "count": 1 }, { "project": 1, "date": "2023-05-27", "count": 1 } ] throws this response. i want gr

Re: group by "project"

2023-05-24 Thread Helly Modi
project'] >> else: >> queryset = RegistrationDatesSlots.objects.all().values( >> 'project', 'date') >> >> serialized_data = [] >> for item in queryset: >> serialized_item = { >>

Re: group by "project"

2023-05-24 Thread Muhammad Juwaini Abdul Rahman
7;date': item['date'], > 'project': item['project'] > } > serialized_data.append(serialized_item) > return Response(serialized_data) > > > this is my views i want to group by "project" bu

group by "project"

2023-05-24 Thread 'Mohamed Yahiya Shajahan' via Django users
ryset: serialized_item = { 'date': item['date'], 'project': item['project'] } serialized_data.append(serialized_item) return Response(serialized_data) this is my views i want to group by &

Problem with group by

2020-11-05 Thread Julio Gorocica
I have some records in the database and I need to group them by the year, the problem is: if the day or month changes then django isn't grouping them. This is my queryset: classifications = ClassificationDocument.objects.filter(Q(area=request_area) and Q(classification__is_active=True)) \

Re: Arbitrary GROUP BY fields

2019-10-19 Thread Integr@te System
Hi Issuer, Bc of you use ORDER BY with .date field so it must include in GROUP BY claude. On Sat, Oct 19, 2019, 09:09 thinkwell wrote: > Thanks for your reply James. I wasn't able to get it to work. > > I posted on the new Django forum > <https://forum.djangoproject.com/

Re: Arbitrary GROUP BY fields

2019-10-18 Thread thinkwell
Thanks for your reply James. I wasn't able to get it to work. I posted on the new Django forum <https://forum.djangoproject.com/t/arbitrary-group-by-fields-for-partitioned-table/369> because it's easier to format code examples over there. Hopefully that clarifies things

Re: Arbitrary GROUP BY fields

2019-10-18 Thread James Gutu
gt; to partition tables > on Django 2.2 & Postgres 11. It's working great as far as that goes, except > that I bumped hard into annotated queries. Since PG can't guarantee PK > uniqueness across partitioned tables, it requires including all fields in > the GROUP BY that

Re: ORM help with INNER JOIN and GROUP BY

2019-05-06 Thread Kevin Jay
*From:* django-users@googlegroups.com [mailto: > django-users@googlegroups.com] *On Behalf Of *b...@tanners.org > *Sent:* Monday, May 6, 2019 12:44 PM > *To:* Django users > *Subject:* Re: ORM help with INNER JOIN and GROUP BY > > > > Just want to make sure I understand. ForeighKeys need

Re: ORM help with INNER JOIN and GROUP BY

2019-05-06 Thread bob
; > *From:* django...@googlegroups.com [mailto: > django...@googlegroups.com ] *On Behalf Of *b...@tanners.org > > *Sent:* Monday, May 6, 2019 11:28 AM > *To:* Django users > *Subject:* ORM help with INNER JOIN and GROUP BY > > > > I've inherited an applicati

Re: ORM help with INNER JOIN and GROUP BY

2019-05-06 Thread Kevin Jay
Maybe that was a typo? The foreignkey relationship would look like this: object = models.ForeignKey(FacePng'', max_length=128, blank=False, null=False, unique=True) On Mon, May 6, 2019 at 12:44 PM wrote: > Just want to make sure I understand. ForeighKeys need to be integers? > > Only integers?

RE: ORM help with INNER JOIN and GROUP BY

2019-05-06 Thread Matthew Pava
: Re: ORM help with INNER JOIN and GROUP BY Just want to make sure I understand. ForeighKeys need to be integers? Only integers? You need a ForeignKey relationship between the two models, which is an integer value, not a char. You’d have to do migrations to get this adjusted properly. -- You

Re: ORM help with INNER JOIN and GROUP BY

2019-05-06 Thread bob
Just want to make sure I understand. ForeighKeys need to be integers? Only integers? You need a ForeignKey relationship between the two models, which is an > integer value, not a char. You’d have to do migrations to get this adjusted > properly. > -- You received this message because you a

Re: ORM help with INNER JOIN and GROUP BY

2019-05-06 Thread Kevin Jay
ote: > > I've inherited an application written django 1.11. The old application uses > raw() with INNER JOIN and GROUP BY. > I cannot seem to figure out how to do inner join and group by properly the > ORM way. > > The raw() query is below. > >

RE: ORM help with INNER JOIN and GROUP BY

2019-05-06 Thread Matthew Pava
users Subject: ORM help with INNER JOIN and GROUP BY I've inherited an application written django 1.11. The old application uses raw() with INNER JOIN and GROUP BY. I cannot seem to figure out how to do inner join and group by properly the ORM way. The raw() query is below. S

ORM help with INNER JOIN and GROUP BY

2019-05-06 Thread bob
I've inherited an application written django 1.11. The old application uses raw() with INNER JOIN and GROUP BY. I cannot seem to figure out how to do inner join and group by properly the ORM way. The raw() query is below. SELECT * FROM items_monolithic INNER JOIN items_facep

Re: column "" must appear in the GROUP BY clause or be used in an aggregate function

2018-10-15 Thread muin
nnotate(cnt=Count("product_specs"), >> min_price=Min("product_specs__price")).filter(cnt__gt=0) >> .order_by("min_price")[offset:offset + limit], >> context={"request": request}, >> many=True) >> >> It says django.db.utils.Programmin

Re: column "" must appear in the GROUP BY clause or be used in an aggregate function

2018-10-15 Thread muin
ice = models.FloatField("价格", default=0) >> ... >> >> When exwcute >> qs = Product.objects.filter(valid=1) >> serializer = ProductSerializer( >> qs.annotate(cnt=Count("product_specs"), >> min_price=Min("product_specs__price")).fil

Re: column "" must appear in the GROUP BY clause or be used in an aggregate function

2018-10-15 Thread ludovic coues
> When exwcute > qs = Product.objects.filter(valid=1) > serializer = ProductSerializer( > qs.annotate(cnt=Count("product_specs"), > min_price=Min("product_specs__price")).filter(cnt__gt=0) > .order_by("min_price")[offset:offset + limit], > context={"re

column "" must appear in the GROUP BY clause or be used in an aggregate function

2018-10-14 Thread muin
t;min_price")[offset:offset + limit], context={"request": request}, many=True) It says django.db.utils.ProgrammingError: column "prome_product.product_name" must appear in the GROUP BY clause or be used in an aggregate function Can anyone help me? -- You received th

Group By Issues with multiple tables

2018-09-17 Thread Pravin Yadav
Hello Friends, I want to use the group by based on "*Itinerary ID*". I hope that *"Values" keywords is using for the "Group By" but when I'm using the **"Values" keywords for group by. then i'm getting the error for fields name.** Like

Re: GROUP BY

2018-08-14 Thread Mikkel Kromann
Thanks for your patience Matthew.I finally got it. I'm still learning the ropes of Django, and I got caught up in multiple errors (the order of lines in the query and picking out query values as dict elements or object elements). The running code with GROUP BY using annotated functions

RE: GROUP BY

2018-08-14 Thread Matthew Pava
users Subject: Re: GROUP BY @galan: the __ is reference to a foreign key name for market, and __year is a function extracting the year from the datefield. Sorry for not posting the model, that would have helped avoiding this. @matthew Yes, that's right. That was one error down. The following

Re: GROUP BY

2018-08-14 Thread Mikkel Kromann
that it doesn't group by week. contract_query = ( Project.objects .values('market__market') .filter(department=department_id) .filter(datePipeline__year=year)

Re: GROUP BY

2018-08-14 Thread Mikkel Kromann
ct')) So, trying to include the week number in my group by is tirsdag den 14. august 2018 kl. 15.28.01 UTC+2 skrev Matthew Pava: > > Ah, the error has the answer. contract_row is a dictionary, so you need > to access it as if it were a dictionary. > > contract_sum = contra

RE: GROUP BY

2018-08-14 Thread Matthew Pava
2018 11:51 PM To: Django users Subject: Re: GROUP BY Thanks. But strange - exactly same error: 'dict' object has no attribute 'contracted' contract_query = (Project.objects.all() .filter(department=department_id)

Re: GROUP BY

2018-08-13 Thread Gagan Kalia
Try not to use _ (underscore) character as prefix or postfix to any user defined variable or db column. Its not recommended in django. On Tue 14 Aug, 2018, 1:52 AM Mikkel Kromann, wrote: > I'm trying to sum the field "ownProduction", grouping it by the foreign > key "market" (using the market's

Re: GROUP BY

2018-08-13 Thread Mikkel Kromann
“ownProduction” in your values list prior to the > annotation. > > > > > > *From:* django...@googlegroups.com [mailto: > django...@googlegroups.com ] *On Behalf Of *Mikkel Kromann > *Sent:* Monday, August 13, 2018 3:22 PM > *To:* Django users > *Subject:

RE: GROUP BY

2018-08-13 Thread Matthew Pava
You need to include “ownProduction” in your values list prior to the annotation. From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Mikkel Kromann Sent: Monday, August 13, 2018 3:22 PM To: Django users Subject: GROUP BY I'm trying to sum the

GROUP BY

2018-08-13 Thread Mikkel Kromann
I'm trying to sum the field "ownProduction", grouping it by the foreign key "market" (using the market's human readable name, __name from the Market table) and the week number (which is built-in function __year of the date field "dateContract"). However, when I try to read the results of the que

Re: A query with "GROUP BY" and summation of products of two columns

2018-08-04 Thread Mikkel Kromann
Apologies. The code I posted is actually correct and well functioning. The reason that the results looked wrong was that the data handled by the code was faulty. In my research, I found another way to do the trick: contracts = (Project.objects.values('stage')

A query with "GROUP BY" and summation of products of two columns

2018-08-04 Thread Mikkel Kromann
Dear Django users. I'm trying to do the sums of the product of two columns ('contract_sum' and 'probability', decimal fields), grouping by a third column, 'stage' (a choice variable). I'm also reporting the grouped sums of one of the single columns ('contract_sum') The single column works just

Re: [Question] Django 2 - how to sum values based on filter and group by Year-Month

2018-07-27 Thread Melvyn Sopacua
On vrijdag 27 juli 2018 04:25:56 CEST Charles Sartori wrote: > I need to Sum() the values filtering it with > 1 - sum(values) where date < first day of the month > 2 - sum(values) where date < last day of the month > > Expected result(something like that): > [ > {'year-month': '2018-01'}, {'sum_

Re: [Question] Django 2 - how to sum values based on filter and group by Year-Month

2018-07-26 Thread Gerald Brown
27;integer field') but I am not able to get the results. I haven't tried grouping yet in my project but will probably have to in the near future.  I think it is possible to group by week & month and then get a sum of those groups.  MariaDB has a function "MONTH" and "

[Question] Django 2 - how to sum values based on filter and group by Year-Month

2018-07-26 Thread Charles Sartori
t_month_day': *70*}, {'year-month': '2018-03'}, {'sum_before_month_day_one': *70*}, {'sum_before_last_month_day': *100*}, ] So far I manage to sum values and group by month: In [12]: result = Sale.objects \ ...: .annotate(date=TruncMonth

Group by object's field and return list of object or object's id for each group

2018-05-07 Thread Aamu Padi
ht=True).annotate(day=TruncDay('booked_at')).values('day').annotate(c=Count('id')).order_by() But I cannot figure out how to group by day and return ticket objects for that day. Could you please help me solve this. Thank you -- You received this message because you ar

Re: GROUP BY behavior change in Django 2.0 with annotate/extra

2018-03-12 Thread Tim Graham
; > In a 1.11 branch I had a complex raw sql snippet added to a query set via > annotate. > > When I updated Django to 2.0, the query set behavior changed to include > the raw sql in the GROUP BY which destroyed the performance. > > The same behavior occurred using annotate

GROUP BY behavior change in Django 2.0 with annotate/extra

2018-03-09 Thread Michael Soderstrom
In a 1.11 branch I had a complex raw sql snippet added to a query set via annotate. When I updated Django to 2.0, the query set behavior changed to include the raw sql in the GROUP BY which destroyed the performance. The same behavior occurred using annotate and extra. I was able to hack

Re: django implementation group by every two hours,

2017-07-13 Thread 'Tom Evans' via Django users
ME_LENGTH, blank=True) >violation_time = models.DateTimeField() > > > > > I have many rows in the database. So I want to group by the results for > every two hours or for every four hours. > I want the result something like > > name violation_date >

django implementation group by every two hours,

2017-07-11 Thread kanhaiya yadav
database. So I want to group by the results for every two hours or for every four hours. I want the result something like name violation_date interval counts abc 2017-07-01

Re: group by 3 fields

2017-03-01 Thread marcin . j . nowak
On Wednesday, March 1, 2017 at 2:09:06 PM UTC+1, larry@gmail.com wrote: > > > I had thought of using a view, but that would have been a lot of > overhead on such a large table. I also considered adding a column and > running a one time script to update the existing rows, and modifying > th

Re: group by 3 fields

2017-03-01 Thread Larry Martell
On Wed, Mar 1, 2017 at 8:01 AM, wrote: > >> >> As is so often the case, the requirements changed. Now what I had to >> do, if I was doing it in SQL would have been: >> >> (CASE >> WHEN TRIM(IFNULL(roiname, '')) IN ('', 'None') THEN CONCAT_WS('.', >> CONVERT(roi_type_id, CHAR), roi_id) >> WHEN C

Re: group by 3 fields

2017-03-01 Thread marcin . j . nowak
> > As is so often the case, the requirements changed. Now what I had to > do, if I was doing it in SQL would have been: > > (CASE > WHEN TRIM(IFNULL(roiname, '')) IN ('', 'None') THEN CONCAT_WS('.', > CONVERT(roi_type_id, CHAR), roi_id) > WHEN CONCAT_WS('.', CONVERT(roi_type_id, CHAR), ro

Re: group by 3 fields

2017-03-01 Thread Larry Martell
ou should be able to do grouping you need Just tell a ORM about aggregates > you want to use, and it will automagically add group by. > > Let's try group by col1, col2: > >> from django.db.models import Count >> from django.contrib.auth.models import User > >> print

Re: group by 3 fields

2017-02-27 Thread marcin . j . nowak
ces for you. We have similar experience, I think. With Django you may play with .aggregate() and .annotate() functions. You should be able to do grouping you need Just tell a ORM about aggregates you want to use, and it will automagically add group by. Let's try group by col1, col2: >

Re: group by 3 fields

2017-02-26 Thread Larry Martell
On Sun, Feb 26, 2017 at 5:05 PM, wrote: > > > On Sunday, February 26, 2017 at 12:55:17 PM UTC+1, Daniel Roseman wrote: >> >> >> You should explain what you want to achieve. Grouping is pointless on its >> own. In any case, when working with an ORM like Django's it is generally not >> helpful to t

Re: group by 3 fields

2017-02-26 Thread Larry Martell
On Sun, Feb 26, 2017 at 6:55 AM, Daniel Roseman wrote: > On Sunday, 26 February 2017 11:11:39 UTC, larry@gmail.com wrote: >> >> Order by is not the same as group by. Group by does aggregation >> > > You should explain what you want to achieve. Grouping is pointles

Re: group by 3 fields

2017-02-26 Thread marcin . j . nowak
On Sunday, February 26, 2017 at 12:55:17 PM UTC+1, Daniel Roseman wrote: > > > You should explain what you want to achieve. Grouping is pointless on its > own. In any case, when working with an ORM like Django's it is generally > not helpful to think in terms of SQL. > -- > DR. > Also forget

Re: group by 3 fields

2017-02-26 Thread Daniel Roseman
On Sunday, 26 February 2017 11:11:39 UTC, larry@gmail.com wrote: > > Order by is not the same as group by. Group by does aggregation > > You should explain what you want to achieve. Grouping is pointless on its own. In any case, when working with an ORM like Django's it

Re: group by 3 fields

2017-02-26 Thread Larry Martell
Order by is not the same as group by. Group by does aggregation On Sun, Feb 26, 2017 at 5:30 AM chris rose wrote: > there is a model meta option called ordering. you can specify a list of > fields to order by > > docs found at: > https://docs.djangoproject.com/en/1.10/ref

Re: group by 3 fields

2017-02-26 Thread chris rose
there is a model meta option called ordering. you can specify a list of fields to order by docs found at: https://docs.djangoproject.com/en/1.10/ref/models/options/#ordering i have only used this in the admin -- You received this message because you are subscribed to the Google Groups "Djang

group by 3 fields

2017-02-25 Thread Larry Martell
I have a query set and I need to do the SQL equivalent of GROUP BY col1, col2, col3 I have read many SO posts about using aggregate and count but I have not been able to get this to work using 3 columns. Anyone know how to do this? -- You received this message because you are subscribed to the

Re: How to GROUP BY in django?

2016-11-03 Thread Melvyn Sopacua
On Thursday 03 November 2016 03:15:31 Awadhesh Meshram wrote: > How to GROUP BY using any identical field in database in Django? https://www.google.com/search?q=django+group+by Grouping is called "aggregation" in DBA lingo. -- Melvyn Sopacua -- You received this message be

Re: How to GROUP BY in django?

2016-11-03 Thread Vinicius Assef
Maybe this can help you: https://docs.djangoproject.com/en/1.10/topics/db/aggregation/ On 3 November 2016 at 08:15, Awadhesh Meshram wrote: > How to GROUP BY using any identical field in database in Django? > > -- > You received this message because you are subscribed to the G

Re: How to GROUP BY in django?

2016-11-03 Thread GMail
lace during database query, I can't help you =/ > On 3 Nov 2016, at 13:15, Awadhesh Meshram wrote: > > How to GROUP BY using any identical field in database in Django? > > -- > You received this message because you are subscribed to the Google Groups > "Django users&qu

How to GROUP BY in django?

2016-11-03 Thread Awadhesh Meshram
How to GROUP BY using any identical field in database in Django? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegrou

Re: Is this behavior with Meta Ordering and Group By expected?

2016-06-29 Thread eric conner
Thanks! I don't see how the link you provided justifies your point. I don't see anything in there saying that specifying an ordering will subsume group by statements. How did you know this was expected? But..in any case I'm happy to take your word for it. And thanks a

Re: Is this behavior with Meta Ordering and Group By expected?

2016-06-29 Thread Fabio C. Barrionuevo da Luz
A.objects.values('b').annotate(most_recent=Max('created_at')) > > Produces this SQL: > SELECT `core_a`.`b_id`, MAX(`core_a`.`created_at`) AS `most_recent` FROM > `core_a` GROUP BY `core_a`.`id` ORDER BY `core_a`.`id` ASC > > which groups by an unexpected

Is this behavior with Meta Ordering and Group By expected?

2016-06-29 Thread eric conner
ost_recent` FROM `core_a` GROUP BY `core_a`.`id` ORDER BY `core_a`.`id` ASC which groups by an unexpected field. I was expecting it to group by `core_a`.`b_id` rather than `core_a`.`id`. Here are my models: from __future__ import unicode_literals from django.db import models from django.utils

Re: GROUP BY without using aggregate function

2016-03-03 Thread marcin . j . nowak
ry handy, in contrast to writing raw sql. I need to add GROUP BY clause only. To be honest I'm waiting for official support for SQLAlchemy in Django, because Django ORM is very limited. But after a while I realized that I should verify performance differences between DISTINCT and GROUP BY.

Re: GROUP BY without using aggregate function

2016-03-03 Thread Michal Petrucha
nct values within big dataset - some queries on some > engines may be faster when using grouping. > It was known technique years ago and I'm still using it. As far as I know, reasonable SQL engines require that every selected column is either in GROUP BY, or wrapped in an aggregatio

Re: GROUP BY without using aggregate function

2016-03-02 Thread marcin . j . nowak
On Wednesday, March 2, 2016 at 6:11:32 PM UTC+1, Dan Tagg wrote: > > if your aren't counting or averaging then why are you grouping? > > > To fast find distinct values within big dataset - some queries on some engines may be faster when using grouping. It was known technique years ago and I'm s

Re: GROUP BY without using aggregate function

2016-03-02 Thread Dan Tagg
if your aren't counting or averaging then why are you grouping? D On 2 March 2016 at 17:06, wrote: > Hello, > > I would like to query database with Django ORM and add GROUP BY clause > without including unnecessary counting, avg, etc. > I can force/hack queryset by settti

GROUP BY without using aggregate function

2016-03-02 Thread marcin . j . nowak
Hello, I would like to query database with Django ORM and add GROUP BY clause without including unnecessary counting, avg, etc. I can force/hack queryset by settting qs.query.group_by=['my_column'], but this is unclean and risky. Is possible something like: MyModel.obje

Re: Django for Data Tables to group by when coloumn hidden

2015-12-14 Thread Sid
ut now I like to > group by when ever I will hide the column. > > > *column1 column2 column3* > > AAACAD25 > > AAAUSD12 > > BBBCAD13 > > BBBUSD16 > > CCCCAD11 > > CCCUSD18 >

Re: Django for Data Tables to group by when coloumn hidden

2015-12-10 Thread Carsten Fuchs
l the concepts that you need in order to build the table with the second column collapsed. Best regards, Carsten Am 09.12.2015 um 16:07 schrieb Sid: *Question:* I have a Data table displaying on django , but now I like to group by when ever I will hide the column. *column1 column2 column3*

Django for Data Tables to group by when coloumn hidden

2015-12-09 Thread Sid
*Question:* I have a Data table displaying on django , but now I like to group by when ever I will hide the column. *column1 column2 column3* AAACAD25 AAAUSD12 BBBCAD13 BBBUSD16 CCCCAD11 CCCUSD18 The above table

Re: programming error in group by clause

2015-01-27 Thread Collin Anderson
n from an older version django-e9d1f11 and I started seeing this > error. Looks like the way group by is constructed has changed. > > Here is the model that I have. > > class everydaycost(models.Model): > cost = models.DecimalField(max_digits=20, decimal_places=2) >

programming error in group by clause

2015-01-24 Thread satya
Need some help on fixing the following error. I recently moved to 1.8alpha version from an older version django-e9d1f11 and I started seeing this error. Looks like the way group by is constructed has changed. Here is the model that I have. class everydaycost(models.Model): cost

Re: Group by using DJango ORM

2013-09-19 Thread Russell Keith-Magee
On Fri, Sep 20, 2013 at 7:34 AM, Nicolas Mendoza wrote: > Actually what's the best way for do a group by using django ORM? > > I know workarounds like combinate "values" with "Anotate", etc. but I > wil like know your favorite workaround without rawSQL and

Group by using DJango ORM

2013-09-19 Thread Nicolas Mendoza
Actually what's the best way for do a group by using django ORM? I know workarounds like combinate "values" with "Anotate", etc. but I wil like know your favorite workaround without rawSQL and not manager based , only Django ORM ;-) Example.objects.values('type

column "cms_pagemoderatorstate.id" must appear in the GROUP BY clause

2012-02-24 Thread Dmitrijs Ledkovs
25 01:34:38 GMT ERROR: column "cms_pagemoderatorstate.id" must appear in the GROUP BY clause or be used in an aggregate function at character 8 2012-02-25 01:34:38 GMT STATEMENT: SELECT "cms_pagemoderatorstate"."id", "cms_pagemoderatorstate"

How to specify a group by field set?

2011-11-22 Thread Joshua Russo
Is there a way to select a list of group by columns? The aggregation methods seem only apply to a single model but I want to use fields from different models to group by. select org.id as organization_id, dep.id as department_id, cat."catId", max(cat.nam

Re: Django aggregation does excessive GROUP BY clauses

2011-11-02 Thread christian.oudard
ggregation using the Django ORM, and it is > > producing a GROUP BY clause that includes the data field, which is > > very large, and is slowing down the query by over 100-fold. > > > Here is a simplified version of the model: > > > class Document(models.Model):

Re: Django aggregation does excessive GROUP BY clauses

2011-11-01 Thread Karen Tracey
On Tue, Nov 1, 2011 at 6:19 PM, christian.oudard wrote: > I am doing a very simple aggregation using the Django ORM, and it is > producing a GROUP BY clause that includes the data field, which is > very large, and is slowing down the query by over 100-fold. > > Here is a simpli

Django aggregation does excessive GROUP BY clauses

2011-11-01 Thread christian.oudard
I am doing a very simple aggregation using the Django ORM, and it is producing a GROUP BY clause that includes the data field, which is very large, and is slowing down the query by over 100-fold. Here is a simplified version of the model: class Document(models.Model): data = models.TextField

Re: order by + group by

2011-09-16 Thread Peter of the Norse
t; Of course you can, using a subselect just like I showed. SQLite example: >> >> > .schema >> CREATE TABLE a (name varchar, mod int); >> >> e> select * from a; >> b1|1 >> b1|2 >> b1|3 >> >> > select * from a group by name; >

Re: When is the django orm going to get a "group by" function ?

2011-09-16 Thread dave bl
On 16 September 2011 22:57, dave bl wrote: > On 16 September 2011 22:39, Jani Tiainen wrote: >> 16.9.2011 15:27, dave bl kirjoitti: >>> >>> Hmm no I am not missing the point... I think the django devs are... >>> sqlalchemy _has_ a group by. >>> >&g

Re: When is the django orm going to get a "group by" function ?

2011-09-16 Thread dave bl
ding >> on the data you are dealing with, and your indexes. >> Put simply - Django does have, nor need, a 'group by' method - and if you >> believe otherwise, it's because you haven't got used to the "Django >> methology" yet. > > > doesn

Re: When is the django orm going to get a "group by" function ?

2011-09-16 Thread dave bl
On 16 September 2011 22:39, Jani Tiainen wrote: > 16.9.2011 15:27, dave bl kirjoitti: >> >> Hmm no I am not missing the point... I think the django devs are... >> sqlalchemy _has_ a group by. >> >> So I simply want to do this sql statement(using the django orm): &

Re: When is the django orm going to get a "group by" function ?

2011-09-16 Thread Cal Leeming [Simplicity Media Ltd]
't perfect, and there are instances where you either > need to use a raw SQL, or split the query up into multiple calls. In some > cases, doing things the 'right' way is actually the 'wrong' way, depending > on the data you are dealing with, and your indexes. &

Re: When is the django orm going to get a "group by" function ?

2011-09-16 Thread Cal Leeming [Simplicity Media Ltd]
doing things the 'right' way is actually the 'wrong' way, depending on the data you are dealing with, and your indexes. Put simply - Django does have, nor need, a 'group by' method - and if you believe otherwise, it's because you haven't got used to the "Dja

Re: When is the django orm going to get a "group by" function ?

2011-09-16 Thread Jani Tiainen
16.9.2011 15:27, dave bl kirjoitti: Hmm no I am not missing the point... I think the django devs are... sqlalchemy _has_ a group by. So I simply want to do this sql statement(using the django orm): select foo, count(foo), from bar group by foo; I _could_ use a .extra method to do this(and get

Re: When is the django orm going to get a "group by" function ?

2011-09-16 Thread dave bl
> Yes, there is. > > Asking for a GROUP BY function in Django's ORM misses the point > entirely of why an ORM exists. Django's ORM isn't SQL. Django's ORM > provides an abstraction layer that is able to make an arbitrary data > store appear like a col

Re: When is the django orm going to get a "group by" function ?

2011-09-16 Thread dave bl
Hmm no I am not missing the point... I think the django devs are... sqlalchemy _has_ a group by. So I simply want to do this sql statement(using the django orm): select foo, count(foo), from bar group by foo; I _could_ use a .extra method to do this(and get stuck on $databases) ... or a loop

Re: When is the django orm going to get a "group by" function ?

2011-09-16 Thread Russell Keith-Magee
On Fri, Sep 16, 2011 at 8:05 PM, dave bl wrote: > When is the django orm going to get a "group by" function ? (this is > srs buz ... Y NO HAZ?). I see that there have been various > changes(getting closer! - with aggregates and annotate) ... and > attempts in the past. Is

Re: When is the django orm going to get a "group by" function ?

2011-09-16 Thread Martin Tiršel
You mean that? https://docs.djangoproject.com/en/1.2/topics/db/aggregation/#values Martin On Fri, 16 Sep 2011 14:05:13 +0200, dave bl wrote: When is the django orm going to get a "group by" function ? (this is srs buz ... Y NO HAZ?). I see that there have been various chang

When is the django orm going to get a "group by" function ?

2011-09-16 Thread dave bl
When is the django orm going to get a "group by" function ? (this is srs buz ... Y NO HAZ?). I see that there have been various changes(getting closer! - with aggregates and annotate) ... and attempts in the past. Is there a "solid" reason for not supporting "grou

Re: order by + group by

2011-09-14 Thread Jani Tiainen
a (name varchar, mod int); e> select * from a; b1|1 b1|2 b1|3 > select * from a group by name; b1|3 > select * from (select * from a order by mod desc) group by name; b1|1 Problem is that is not standard SQL. In standard implemetation group by _requires_ aggregation function that is

Re: order by + group by

2011-09-14 Thread Jonas H.
from a; b1|1 b1|2 b1|3 > select * from a group by name; b1|3 > select * from (select * from a order by mod desc) group by name; b1|1 -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django

Re: order by + group by

2011-09-14 Thread Иван Иванов
На Wed, 14 Sep 2011 10:59:01 +0200 "Jonas H." написа: > On 09/14/2011 04:35 AM, Peter of the Norse wrote: > > What are you trying to do? The outer GROUP BY destroys the inner > > ORDER BY. Try putting them on the same level and see what happens. > > Say I've

Re: order by + group by

2011-09-14 Thread Jonas H.
On 09/14/2011 04:35 AM, Peter of the Norse wrote: What are you trying to do? The outer GROUP BY destroys the inner ORDER BY. Try putting them on the same level and see what happens. Say I've got an Event table and some records like this name: foo, timestamp: 9 pm name: foo, time

Re: order by + group by

2011-09-13 Thread Peter of the Norse
What are you trying to do? The outer GROUP BY destroys the inner ORDER BY. Try putting them on the same level and see what happens. On Sep 11, 2011, at 3:41 AM, Jonas H. wrote: > Hi! > > How can I express this SQL query > > SELECT ... FROM ( >SELECT ... FROM ... &g

order by + group by

2011-09-11 Thread Jonas H.
Hi! How can I express this SQL query SELECT ... FROM ( SELECT ... FROM ... ) in the ORM? Specifically, I want to express SELECT ... FROM ( SELECT ... FROM app_model ORDER BY field1 ) GROUP BY field2 Is it possible without writing SQL by hand? Thanks, Jonas -- Django

Re: group by and retrieve to template date from foreinKey

2011-07-15 Thread nicolas HERSOG
Oh sorry, I knew that my sql query was naive, but my question was really about how to use group by and retrieve data throug my template :/ I'm really sorry for waste your time with stupid sql. Nevertheless a great thank you for your help. I'm going to do like you say and in few tim

Re: group by and retrieve to template date from foreinKey

2011-07-15 Thread bruno desthuilliers
3 | vids3 | 2011-07-13 | 1 | | 4 | vids4 | 2011-07-15 | 2 | | 5 | vids5 | 2011-07-14 | 2 | | 6 | vids6 | 2011-07-15 | 3 | ++---++-+ mysql> select * from video group by category_id; ++---++-

Re: group by and retrieve to template date from foreinKey

2011-07-15 Thread nicolas HERSOG
...) > > category = models.ForeignKey('Category') > >(...) > > > > class Category(models.Model): > > name = models.CharField(max_length=250) > > > > I'm trying in a tags to make a group by on the category field and > &g

Re: group by and retrieve to template date from foreinKey

2011-07-15 Thread bruno desthuilliers
odels.Model): >     name = models.CharField(max_length=250) > > I'm trying in a tags to make a group by on the category field and > retrieve in the template the name of the first vid and its category > name. > > Here it s my teamplate.py : > > @register.

Re: group by and retrieve to template date from foreinKey

2011-07-15 Thread Venkatraman S
concise reply : I would strongly suggest you to have a look at django-taggit. OTOH, use django-debug-toolbar to diagnose the sql that is being fired. -V -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django

group by and retrieve to template date from foreinKey

2011-07-15 Thread Suprnaturall
Hi dear django users :) I m facing a stupid problem. Here is my models.py : class Video(models.Model): (...) category = models.ForeignKey('Category') (...) class Category(models.Model): name = models.CharField(max_length=250) I'm trying in a tags to make a

  1   2   >