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
On Mon, Feb 27, 2017 at 3:41 AM, wrote: > > > On Monday, February 27, 2017 at 3:52:38 AM UTC+1, larry@gmail.com wrote: >> >> [SQL] That is a language I >> have worked in for over 20 years, and when I see a querying need that >> is how I think, and then I see how can I do that with the ORM. >

Re: group by 3 fields

2017-02-27 Thread marcin . j . nowak
On Monday, February 27, 2017 at 3:52:38 AM UTC+1, larry@gmail.com wrote: > > [SQL] That is a language I > have worked in for over 20 years, and when I see a querying need that > is how I think, and then I see how can I do that with the ORM. > So I shouldn't give advices for you. We have s

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 pointless on its > own. In any case, w

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 is generally not help

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/models/options/#orderin

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