On Fri, 2002-11-29 at 01:17, Ron St.Pierre wrote:
> I'm using a query with similar functionality to the following:
>
> SELECT id,
> sum(hours) AS totalhours
> FROM mytable
> WHERE totalhours > 50;
>
> I get the following error:
> Attribute 'totalhours' not found.
>
> Am I not allowed to use an alias here? If not, how can I get my desired
> output?
select id, sum(hours) as totalhours
from mytable
group by id
having totalhours > 50
'where' is for tuple selection criteria
'having' is for group selection criteria
i suppose you want to have the total number of hours per id (therefore
we need to group by id.
Does this help ?
Tycho