| counting in my sql XxY [message #3057] |
Fri, 09 May 2008 05:36  |
delta2cain1 Messages: 7 Registered: May 2008 |
Junior Member |
|
|
Hi I have a table with 2 columns Name (variable type) and CODE (variable type)
I need to retrieve a result in the following format
NAME -->
CODE
| FREQUENCY
|
V
The number of names may vary
so also the code
I Need to write a query in MySQL
Please point me in the right direction.
|
|
|
|
|
|
|
|
|
|
| Re: counting in my sql XxY [message #3071 is a reply to message #3057 ] |
Mon, 12 May 2008 08:38   |
delta2cain1 Messages: 7 Registered: May 2008 |
Junior Member |
|
|
the actual query was
EXPLAIN SELECT Errorcode , count(*) AS "Count", ClientName FROM customer_profile_SMM WHERE ClientName IN (SELECT DISTINCT a.ClientName FROM customer_profile_SMM a) GROUP BY Errorcode,ClientName;
1) EXPAIN SELECT ABC , count(*) AS "Count", XYZ FROM profile WHERE XYZ IN (SELECT DISTINCT a.XYZ FROM profile a) GROUP BY ABC,XYZ
+----+--------------------+----------------------+-------+-- -------------+-------------+---------+------+---------+----- --------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+--------------------+----------------------+-------+-- -------------+-------------+---------+------+---------+----- --------------------------------------+
| 1 | PRIMARY | customer_profile_SMM | index | NULL | Errorcode_2 | 65 | NULL | 3785102 | Usingwhere; Using index |
| 2 | DEPENDENT SUBQUERY | a | index | NULL | Errorcode_2 | 65 | NULL | 3785102 | Usingwhere; Using index; Using temporary |
+----+--------------------+----------------------+-------+-- -------------+-------------+---------+------+---------+----- --------------------------------------+
2) show create table profile
ERROR 1146 (42S02): Table 'Data_base.profile' doesn't exist
[Updated on: Mon, 12 May 2008 08:40]
|
|
|
|
| Re: counting in my sql XxY [message #3073 is a reply to message #3057 ] |
Mon, 12 May 2008 09:45  |
delta2cain1 Messages: 7 Registered: May 2008 |
Junior Member |
|
|
|
g
[Updated on: Thu, 15 May 2008 02:21]
|
|
|