Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM SQL » View Thread |
Messages 1 to 2 of 2 total |
Newbie select question |
Thu, Sep 27 2007 1:11 PM | Permanent Link |
Kai | I need to find all donors from a donations table who have donated more than amount (x) in total. If I could use donsum in the where clause as show below, I'd be happy. But since I cannot, how do I achieve what I need? TIA Kai select donorid, donorname, donoraddress1, donoraddress2, sum(donationamount) as donsum from donations where donsum > 100 group by donorid order by donsum |
Thu, Sep 27 2007 4:15 PM | Permanent Link |
"Jeff Cook" | Kia Orans Kai
You need the "HAVING" Clause ... HAVING Clause The HAVING clause specifies filtering conditions for a SELECT statement. The syntax is as follows: HAVING predicates Use a HAVING clause to limit the rows retrieved by a SELECT statement to a subset of rows where aggregated column values meet the specified criteria. A HAVING clause can only be used in a SELECT statement when: .. The statement also has a GROUP BY clause. .. One or more columns are the subjects of aggregate functions. The value for a HAVING clause is one or more logical expressions, or predicates, that evaluate to true or false for each aggregate row retrieved from the table. Only those rows where the predicates evaluate to true are retrieved by a SELECT statement. For example, the SELECT statement below retrieves all rows where the total sales for individual companies exceed $1,000: SELECT Company, SUM(sales) AS TOTALSALES FROM Sales1998 GROUP BY Company HAVING (SUM(sales) >= 1000) ORDER BY Company -- Jeff Cook Aspect Systems Ltd www.aspect.co.nz + Joan and Jeff Cook The Cooks Oasis www.cookislandsoasis.com |
This web page was last updated on Tuesday, May 7, 2024 at 02:40 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |