Re: [SQL] join/group/count query.

2006-12-21 Thread Gary Stainburn
On Wednesday 20 December 2006 18:06, Hector Villarreal wrote: > HI in reading this is it possible what was really intended : > Sum(case when o_model = 5 then 1 else NULL end) as KA > That would provide a count of all records meeting that condition. > Otherwise the count( approach will not do that.

Re: [SQL] join/group/count query.

2006-12-20 Thread Hector Villarreal
:[EMAIL PROTECTED] On Behalf Of Gary Stainburn Sent: Wednesday, December 20, 2006 8:20 AM To: pgsql-sql@postgresql.org Subject: Re: [SQL] join/group/count query. > > And, I may be missing something, but I'm having a hard time > understanding why you have all of those select columns

Re: [SQL] join/group/count query.

2006-12-20 Thread Erik Jones
Gary Stainburn wrote: And, I may be missing something, but I'm having a hard time understanding why you have all of those select columns of the form: count (case when o_model = 5 then 1 else NULL end) as KA, Considering that that can only return 1 or 0, the case statement would do. Is it to

Re: [SQL] join/group/count query.

2006-12-20 Thread Gary Stainburn
> > And, I may be missing something, but I'm having a hard time > understanding why you have all of those select columns of the form: > > count (case when o_model = 5 then 1 else NULL end) as KA, > > Considering that that can only return 1 or 0, the case statement would do. > Is it to avoid putt

Re: [SQL] join/group/count query.

2006-12-20 Thread Erik Jones
Ragnar wrote: On mið, 2006-12-20 at 10:12 +, Gary Stainburn wrote: Hi folks. I have the following query which works for me at the moment. However, o_model refers to a table stock_models which has one record for each model type. At the moment if I another record to the stock_models I ha

Re: [SQL] join/group/count query.

2006-12-20 Thread Ragnar
On mið, 2006-12-20 at 10:12 +, Gary Stainburn wrote: > Hi folks. I have the following query which works for me at the moment. > However, o_model refers to a table stock_models which has one record for each > model type. At the moment if I another record to the stock_models I have to > amen

[SQL] join/group/count query.

2006-12-20 Thread Gary Stainburn
Hi folks. I have the following query which works for me at the moment. However, o_model refers to a table stock_models which has one record for each model type. At the moment if I another record to the stock_models I have to amend the select. Is it possible to make this automatic by joining t