Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 14th, 2010, 07:16 AM
Authorized User
 
Join Date: Sep 2008
Posts: 54
Thanks: 8
Thanked 1 Time in 1 Post
Default How to use 'HAVING' without 'GROUP BY'?

Hi!

'Having' can be used without 'Group by' as well, table has the data but this query is not returning any answers is there anything wrong with this query?

SELECT SUM(ACCOUNT_TYPE)
FROM TBLCUSTCHANNEL
HAVING SUM(ACCOUNT_TYPE) <=10



Thanks in advance
 
Old October 16th, 2010, 07:05 AM
Authorized User
 
Join Date: Oct 2010
Posts: 64
Thanks: 0
Thanked 16 Times in 16 Posts
Default HAVING without GROUP BY

I think your problem here is that by NOT specifying a GROUP BY clause ALL records are grouped into one group, so if the total of all your records sums up to more than 10 and you then filter out that one record with the HAVING clause you don't get a result.
If you reduced your records so that the sum of them adds up to less than 10 or change the figure to say 10000000 or more if required then it will work.

HTH.
 
Old October 16th, 2010, 02:38 PM
Authorized User
 
Join Date: Sep 2008
Posts: 54
Thanks: 8
Thanked 1 Time in 1 Post
Default Thanks, your answer had the solution

Thanks, your answer had the solution
__________________
How to do programming?





Similar Threads
Thread Thread Starter Forum Replies Last Post
Group Within another Group, xslt1.0 jhansib4u BOOK: XSLT Programmer's Reference, 2nd Edition 4 November 22nd, 2007 01:24 AM
Restart new group number in Group Footer sukarso Crystal Reports 2 October 13th, 2006 12:11 PM
Group by , Sub Group by and Sum mateenmohd SQL Server 2000 1 March 29th, 2005 09:51 AM
Group By btpoole VB Databases Basics 0 February 27th, 2004 11:56 AM
Group By andrekl SQL Server 2000 16 November 10th, 2003 11:33 AM





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