COUNT question

2010-10-18 Thread Tompkins Neil
Hi, I've the following query SELECT COUNT(players_id) AS players_count FROM players WHERE teams_id > 0 GROUP BY teams_id ORDER BY players_count DESC However, I've another field called original_teams_id and want to include the COUNT with players_count, when original_teams_id = teams_id Cheers Ne

Re: COUNT question

2006-09-18 Thread Jørn Dahl-Stamnes
On Monday 18 September 2006 14:55, Brent Baisley wrote: > You might try changing it to distinct if you are looking for unique count > of ids from each. SELECT a.a,aa,COUNT(DISTINCT b.id),COUNT(DISTINCT c.id) > FROM... This return 0 or 1 for b.id (1 if there is 1 or more records) and the correct v

Re: COUNT question

2006-09-18 Thread Brent Baisley
y work to filter out duplicates like NULL. Otherwise you'll need to do it long hand: SELECT a.a,aa,COUNT(IF(b.id IS NULL,0,1)),COUNT(IF(c.id IS NULL,0,1)) FROM... - Original Message - From: "Jørn Dahl-Stamnes" <[EMAIL PROTECTED]> To: Sent: Monday, September 18, 2006

Re: COUNT question

2006-09-18 Thread Johan Höök
Hi Jörn, I don't think you can do it in one SELECT as you'll get the same number (the max) as soon as the COUNT goes above zero. If you think about how your resultset looks if you remove your COUNTs it becomes clearer. Say that for one a.a you have 3 matches in b and 2 matches in c, this will resu

COUNT question

2006-09-18 Thread Jørn Dahl-Stamnes
I have a query like: SELECT a.a,aa,COUNT(b.id),COUNT(c.id) FROM a LEFT JOIN b ON (b.a_ref=a.id) LEFT JOIN c ON (c.a_ref=a.id); But it seems like SQL is mixing up the two count's. I get the count from table c instead of table b for the first occurence of COUNT in the query. Can I use two COUNT'

Re: simpe select count question

2006-04-20 Thread Dan Buettner
Andras - If you create an additional table which contains all possible values for the order_status field, you can do this. Something like this: create table orderstatus ( statusname varchar(25) ); insert into orderstatus (statusname) values ('pending'), ('processing'), ('shipped'); Next yo

simpe select count question

2006-04-20 Thread Andras Kende
Hello, I would like merge this 3 query into a single one... SELECT COUNT(*) AS count FROM orders WHERE order_status = 'pending', SELECT COUNT(*) AS count FROM orders WHERE order_status = 'processing', SELECT COUNT(*) AS count FROM orders WHERE order_status = 'shipped', I could do : SELECT orde

Re: SELECT COUNT(*) question ...

2001-08-21 Thread shiuwaitai
. Then total number of records is the last sum-up. - Original Message - From: "G r e g L a w r i e" <[EMAIL PROTECTED]> To: "MySQL Mailing List" <[EMAIL PROTECTED]> Sent: Tuesday, August 21, 2001 2:15 PM Subject: SELECT COUNT(*) question ... > Howdy all, &

SELECT COUNT(*) question ...

2001-08-20 Thread G r e g L a w r i e
Howdy all, I have two tables as described further down below ... I use the following query to get the data I need ... sql = "SELECT tblTempConsolidation.*, tblCustomer.customerLibrary FROM tblCustomer, tblTempConsolidation WHERE tblCustomer.customerId = tblTempConsolidation.customerId AND tblTe

Re: [Fwd: Re: COUNT question]

2001-01-27 Thread Bob Hall
> Update, which may be helpful: > > The number I'm getting back (which I said is vastly too high) is in >fact the number of pictures multiplied by the number of ratings entries >for that artist. > I wanted to be able to get those two groupings separately. Is there a >way I can d

[Fwd: Re: COUNT question]

2001-01-26 Thread Brian Tiemann
Update, which may be helpful: The number I'm getting back (which I said is vastly too high) is in fact the number of pictures multiplied by the number of ratings entries for that artist. I wanted to be able to get those two groupings separately. Is there a way I can do th

COUNT question

2001-01-26 Thread Brian Tiemann
Hi-- I'm running an art archive, and for the artist listing pages I have to come up with a query something like the following: select name,dirname,sortname,pictures.artistid,count(pictures.artistid) as imgnum,avg(rating) as rateavg,max(uploaded) as lastmod from artists,pictures,r