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
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.
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
>
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
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.
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
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