Re: help with count in grouped query
On Jan 10, 2008 5:40 PM, Eben [EMAIL PROTECTED] wrote: I want to be able to do count of the total records brought back by this query... but since I am using the group by I can't use COUNT() in the desired way. Assuming what you want is all the data from your current query plus an additional row showing a full count, you can use WITH ROLLUP to get it. Or just do a separate COUNT query without the GROUP BY. - Perrin -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Help with count(*)
On Mon, 11 Aug 2003, gord barq wrote: I have a table I'm using for logging purposes with a schema like: create table results ( user varchar(255) ); Where user is not a unique field and I want to find out how many unique users there are in the table. I want to do something like: select count(count(*)) from results group by user; But that doesn't work.. Hello, How about SELECT COUNT(DISTINCT user) FROM results? Hope this helps. Cheers, Tan Shao Yi -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Help with count(*)
select count(distinct(user)) from results; Cheers, Jan -- Janice Wright Ingenta plc [EMAIL PROTECTED] Tel: +44 (0) 01865 799114 http://www.ingentaselect.com/ Sometime recently Daniel Rossi said: what ever happend to a unique primary key like userID ? gord barq [EMAIL PROTECTED] 08/11/03 11:15am I have a table I'm using for logging purposes with a schema like: create table results ( user varchar(255) ); Where user is not a unique field and I want to find out how many unique users there are in the table. I want to do something like: select count(count(*)) from results group by user; But that doesn't work.. Any ideas? Thanks -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Help with count(*)
what ever happend to a unique primary key like userID ? gord barq [EMAIL PROTECTED] 08/11/03 11:15am I have a table I'm using for logging purposes with a schema like: create table results ( user varchar(255) ); Where user is not a unique field and I want to find out how many unique users there are in the table. I want to do something like: select count(count(*)) from results group by user; But that doesn't work.. Any ideas? Thanks _ STOP MORE SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: Help with count(*)
what ever happend to a unique primary key like userID ? User is not the primary key. This is a logging table so the primary key is likely to be a timestamp of some sort. Read the question. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Help with count(*)
At 08:15 PM 8/10/2003, you wrote: I have a table I'm using for logging purposes with a schema like: create table results ( user varchar(255) ); Where user is not a unique field and I want to find out how many unique users there are in the table. I want to do something like: select count(count(*)) from results group by user; But that doesn't work.. Any ideas? Thanks Try select user, count(*) Num from results group by user you can also sort the results by: select user, count(*) Num from results group by user order by Num Mike -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]