473,508 Members | 2,265 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Doubt in COUNT(*)

ganeshkumar08
31 New Member
HI SQL Friends

Can any one you help me please..
The below is the query

SELECT COUNT([dbo].[User].[Name]) FROM [dbo].[User]
WHERE [dbo].[User].[Name]='GaneshKumar' GROUP BY [dbo].[User].[Name] HAVING (COUNT([dbo].[User].[Name]) = 1)

In the above query the WHERE condition is satisfied then the result will be a integer value. If the codition is not satisfied the no row is returned.

My problem is, if now row is returned it should return 0 value,

Can any one help me please

Thanks
Ganesh Kumar V
Feb 24 '08 #1
3 1229
jagged
23 New Member
SELECT COUNT(user.name) FROM Users where .... returns 0 if there are no records.

I'm not sure if you're trying to do something else, but from the looks of it, you don't need the group by / having at all.
Feb 24 '08 #2
ganeshkumar08
31 New Member
I tried like below...

SELECT COUNT(dbo.[user].[name]) FROM dbo.[User] where dbo.[User].[Name]='bb' GROUP BY dbo.[User].[Name]

The above query returns no record.
But for me i need to display 0(zero)
Feb 24 '08 #3
jagged
23 New Member
I tried like below...

SELECT COUNT(dbo.[user].[name]) FROM dbo.[User] where dbo.[User].[Name]='bb' GROUP BY dbo.[User].[Name]

The above query returns no record.
But for me i need to display 0(zero)

Don't use GROUP BY

select count(user.name) from user where user.name = 'bb'

that's it. Don't add anything else after
Feb 24 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

20
2289
by: K.M. Jr. | last post by:
Hi all, Consider this line - char s = "\0"; Does this initialize all array elements to zero ? Thanks.
77
3616
by: muttaa | last post by:
Hello all, My doubt is going to be so primitive that i ask you all to forgive me beforehand.... Here's the code snippet: int main() { int x=5;
6
1502
by: deepak | last post by:
main() { int *a=NULL; int *b; a = (int *) malloc(sizeof(int)); *a=10; b=a;
4
2039
by: Anarki | last post by:
##include <iostream> using namespace std; class A { }; class B:virtual public A { }; class C:virtual public A
2
2524
priyan
by: priyan | last post by:
hi all, I am having a doubt of how to write a function for my situation. I am having two tables portfolioscrip portfolioscripdetails i have to insert into...
21
1371
by: Fastro | last post by:
int myfun(char *sourcebuf) { char *destbuf; char ch; while (*sourcebuf != '\0') { *destbuf++=*sourcebuf++; --crashed here }; return 1; }
4
1560
by: pavanponnapalli | last post by:
hi, Here is my Code as under: #! /usr/bin/perl -w use DBI; my %hash; my @arr; my @arr1; my @arr2;
2
1536
by: solvemyqueries | last post by:
hi friends. i had to execute this query,but it post a error saying"its not a group function" The query is "select name,count(trainingdates) from tablenames group by having...
0
7132
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7401
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7063
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5059
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3196
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
773
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
432
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.