Re: [GENERAL] remove some rows from resultset

2012-04-19 Thread Alban Hertroys
On 19 Apr 2012, at 6:26, Ondrej Ivanič wrote: > I have query which does everything but I have mixed feelings about it: > select >b1.org_id, b1.contract_name, coalesce(b2.count, b1.count) as count > from (select * from billing where org_specific_rule = false) as b1 > left join billing b2 on >

Re: [GENERAL] remove some rows from resultset

2012-04-19 Thread Willy-Bas Loos
should work. you could move b1 out of the sub query and add a normal where clause to make the syntax nicer. Might also matter for the query plan. other than that i don't see any bumps. It's good that you placed "b2.org_specific_rule = true" in the join clause so that the left join works properly. w

[GENERAL] remove some rows from resultset

2012-04-18 Thread Ondrej Ivanič
Hi, I have the following table: org_id | contract_name | org_specific_rule | count --+--+---+--- smpj28p2 | Group 123| f | 3 smpj28p2 | Group 2 | f | 3 smpj28p2 | Group 2 | t