Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server ASP
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
SQL Server ASP Discussions about ASP programming with Microsoft's SQL Server. For more ASP forums, see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server ASP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 11th, 2004, 11:10 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default HAVING clause

I'm getting an error with this statement

select email from competition where Answer =
'Ripple' and email having count(*)> '1' group by email

The error is:

Incorrect syntax near the keyword 'having'.

Also, the email column is not of an int type so I don't know if > 1 will work with it. Basically, I'm trying to find out if there are more than 1 duplicate email entry.

Thanks

Adam
Reply With Quote
  #2 (permalink)  
Old February 11th, 2004, 12:40 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Hudson, MA, USA.
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

The HAVING clause is a separate clause in the SELECT statement, similar to the WHERE clause. It works just like the WHERE clause, but it selects (grouped) rows after the GROUPing operation. The WHERE clause selects rows before GROUPing is done. Since COUNT is an aggregate function, you must use a GROUP by clause to arrange for rows to be grouped by the value of the 'email' column:
Code:
SELECT email FROM competition
   WHERE Answer='Ripple'
GROUP BY email
HAVING COUNT(*)>1;
Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
Reply With Quote
  #3 (permalink)  
Old February 11th, 2004, 01:37 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default

Right, I got you - thanks alot Jeff
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Case in Where Clause acko SQL Server 2000 12 September 12th, 2011 01:43 PM
date between clause mateenmohd Access 2 January 7th, 2008 09:28 AM
SQL Where Clause sudarshan73 Crystal Reports 2 January 11th, 2006 10:01 AM
Order by clause mateenmohd SQL Server 2000 4 April 6th, 2004 06:48 AM
More than 1 WHERE clause? onlyu2 MySQL 1 March 26th, 2004 01:48 PM



All times are GMT -4. The time now is 09:14 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.