Use the DISTINCT keyword and count the returned rows
- Original Message -
From: Jamie Burns [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, September 14, 2001 9:08 AM
Subject: surely an easy quick one
Hello again :o)
This is surely an easy quick one but my brain wont work!
I
that this is the book that you should get. But if
you want to increase your SQL knowledge, you should look into getting
something.
Cheers,
Richard
From: Jamie Burns [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, September 14, 2001 9:08 AM
Subject: surely an easy quick one
Hello again :o
Hello again :o)
This is surely an easy quick one but my brain wont work!
I have a table (ref, name, team, seminar_ref) like:
1billsupport100
2billsupport101
3billsupport102
4ben development 201
5ben development 103
6
select count(*) from table where team='support' group by team
-Ursprüngliche Nachricht-
Von: Jamie Burns [mailto:[EMAIL PROTECTED]]
Gesendet: Freitag, 14. September 2001 15:09
An: [EMAIL PROTECTED]
Betreff: surely an easy quick one
Hello again :o)
This is surely an easy quick one
an easy quick one
Hello again :o)
This is surely an easy quick one but my brain wont work!
I have a table (ref, name, team, seminar_ref) like:
1billsupport100
2billsupport101
3billsupport102
4ben development 201
5ben
select count(*) from table where team='support' group by team
I think that should be a group by name not by team.
--
Colin
-
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
your query
gets 9 from).
:o(
- Original Message -
From: Stefan Pinkert [EMAIL PROTECTED]
To: Jamie Burns [EMAIL PROTECTED];
[EMAIL PROTECTED]
Sent: Friday, September 14, 2001 2:25 PM
Subject: Re: surely an easy quick one
select count(*) from table where team='support' group by team
Hi,
idname group_name
--
1bill support 100
2bill support 101
3bill support 102
4bendevelopment 201
5bendevelopment 103
6bendevelopment 204
7bobsupport
];
[EMAIL PROTECTED]
Sent: Friday, September 14, 2001 2:29 PM
Subject: Re: surely an easy quick one
I haven't tested this; I'm not an SQL guru. I just
like a challenge :-)
SELECT COUNT(*) FROM table WHERE team = support GROUP BY name;
Lezz Giles
- Original Message -
From: Jamie
.
- Original Message -
From: Lezz Giles [EMAIL PROTECTED]
To: Jamie Burns [EMAIL PROTECTED];
[EMAIL PROTECTED]
Sent: Friday, September 14, 2001 2:29 PM
Subject: Re: surely an easy quick one
I haven't tested this; I'm not an SQL guru. I just
like a challenge :-)
SELECT COUNT(*) FROM table WHERE
this doesnt work as i need either :o(
it returns 3 rows, each with a count of 3 inside. i just want to get a
*single row* with the number 3 in it (for my example).
You just need to add another clause to the where statement
SELECT COUNT(*) FROM table WHERE team = support AND user=bob
Subject: Re: surely an easy quick one
this doesnt work as i need either :o(
it returns 3 rows, each with a count of 3 inside. i just want to get a
*single row* with the number 3 in it (for my example).
:o(
thanks for trying though...
- Original Message -
From: Lezz Giles [EMAIL
Please ignore my last post. I had lost track of what you were trying to
achieve with your query.
--
Colin
-
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
Hi,
SELECT COUNT(DISTINCT name) from tester WHERE team = 'support'
Could 2 queries do the trick?
insert into temptable
select count(name) from tester
where team = 'support'
group by team;
select count(*) from temptable;
Best Regards,
Sasa
P.S. create table temptable(tempfield
O.k, how about this query.
SELECT DISTINCT name,count(1) AS numPeople FROM tester Where team
='support'
GROUP BY team
Its a bit dirty and it returns an extra column, but this could be ignored
--
Colin
-
Before posting,
If you want a count for a specific team:
Select count(*) From table Where team = 'support';
If you want the counts for all the teams:
Select team, count(*) From table Group By team;
- Original Message -
From: Jamie Burns [EMAIL PROTECTED]
I have a table (ref, name, team, seminar_ref)
Woops! Nevermind. I didn't notice your data was denormalized.
- Original Message -
From: Chris Johnson [EMAIL PROTECTED]
To: Jamie Burns [EMAIL PROTECTED];
[EMAIL PROTECTED]
Sent: Friday, September 14, 2001 10:33 PM
Subject: Re: surely an easy quick one
If you want a count
17 matches
Mail list logo