List:General Discussion« Previous MessageNext Message »
From:Abhishek Choudhary Date:April 14 2012 3:28pm
Subject:Fw: Simple Query Question
View as plain text  

Hi ,
count() function is a group function so use group by clause  in your select
statement if you are selecting more than one column data..

here is some sample query related to help you,

select count(*)   from trndisburse:

output:1467

select count(*),pkdisburseid from trndisburse_TMP m Group by
 pkdisburseid;

output:
COUNT(*)    PKDISBURSEID

1    000100001120414090807001226
1    000100001120414090807001228
1    000100001120414090807001246
1    000100001120414090807001252
1    000100001120414090807001173
1    000100001120414090807001187
1    000100001120414090807001230
1    000100001120414090807000859
1    000100001120414090807000042
1    000100001120414090807000051
1    000100001120414090807000097
1    000100001120414090807001309
1    000100001120414090807001314
1    000100001120414090807001333
1    000100001120414090807001290
1    00010000112041409
0807000001
..............................
......some more  data...........

last equivlent to your  problem:

select count(pkdisburseid) from trndisburse_TMP m
where grossamt>=6000
  Group by pkdisburseid;

select count(pkdisburseid),grossamt from trndisburse_TMP m
where grossamt>=6000
  Group by pkdisburseid,grossamt;

Thanks ,
abhisehk choudhary
www.tech4urhelp.blogspot.com


________________________________
 From: Stefan Kuhn <stefhk3@stripped>
To: mysql@stripped 
Sent: Saturday, 14 April 2012 4:51 PM
Subject: Re: Simple Query Question
 
On Saturday 14 April 2012 09:51:11 Willy Mularto wrote:
> Hi,
> Please help what is wrong with this simple query "SELECT COUNT(key_agent)
> total FROM agents_consolidated  WHERE total = 180" Thanks.
You need to use having instead of where, see the documentation.
Stefan
>
>
>
> Willy Mularto
> F300HD+MR18DE (NLC1725)



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql
Thread
Fw: Simple Query QuestionAbhishek Choudhary14 Apr