Re: Problems with WHERE clause

2006-07-30 Thread Michael Stassen
Jørn Dahl-Stamnes wrote: > I got the following query: > > select s.id,s.name,sum(p.fee) as fee from serie as s inner join race_serie as > rs on (rs.serie_id=s.id) inner join races as r on (r.id=rs.race_id) inner > join participants as p on (p.race_id=r.id) where s.receipt=1 and > p.rider_id=236 an

Re: Problems with WHERE clause

2006-07-30 Thread Martin Jespersen
Do the right thing(TM) and don't use an alias that is the same as a field that exists (this was mentioned before by someone else). Since there is a field in your join named "fee", using "fee" as an alias, is bound to cause your trouble. Also, trying to call sum(p.fee) twice is a waste of cputime.

Re: Problems with WHERE clause

2006-07-30 Thread Jørn Dahl-Stamnes
On Sunday 30 July 2006 12:37, Gabriel PREDA wrote: > You must specify explicitly what 'fee' to use... so if you wand every > p.fee to be greater than zero then you must do: > > SELECT s.id, s.name, SUM(p.fee) AS fee > FROM serie AS s > INNER JOIN race_serie AS rs ON rs.serie_id = s.id >

Re: Problems with WHERE clause

2006-07-30 Thread Gabriel PREDA
You must specify explicitly what 'fee' to use... so if you wand every p.fee to be greater than zero then you must do: SELECT s.id, s.name, SUM(p.fee) AS fee FROM serie AS s INNER JOIN race_serie AS rs ON rs.serie_id = s.id INNER JOIN races AS r ON r.id = rs.race_id INNER JOIN particip

Re: Problems with WHERE clause

2006-07-30 Thread Visolve DB Team
DB Team - Original Message - From: "Jørn Dahl-Stamnes" <[EMAIL PROTECTED]> To: Sent: Sunday, July 30, 2006 2:40 PM Subject: Problems with WHERE clause I got the following query: select s.id,s.name,sum(p.fee) as fee from serie as s inner join race_serie as rs on (rs.

Re: Problems with WHERE clause

2006-07-30 Thread Chris Sansom
At 11:10 +0200 30/7/06, Jørn Dahl-Stamnes wrote: select s.id,s.name,sum(p.fee) as fee from serie as s inner join race_serie as rs on (rs.serie_id=s.id) inner join races as r on (r.id=rs.race_id) inner join participants as p on (p.race_id=r.id) where s.receipt=1 and p.rider_id=236 and fee > 0 grou

Problems with WHERE clause

2006-07-30 Thread Jørn Dahl-Stamnes
I got the following query: select s.id,s.name,sum(p.fee) as fee from serie as s inner join race_serie as rs on (rs.serie_id=s.id) inner join races as r on (r.id=rs.race_id) inner join participants as p on (p.race_id=r.id) where s.receipt=1 and p.rider_id=236 and fee > 0 group by s.id order by s