Shubham Jairath
Shubham Jairath

Reputation: 392

Finding average of the column generated from sql query having group by function

I want to find the average of the following data via mysql query (assume these are 719 rows).

|        1 |
|        3 |
|        1 |
|        2 |
|        2 |
|        1 |
|        1 |
|        2 |
|        1 |
|        1 |
|        2 |
|        1 |
|        2 |
|        1 |
|        2 |
|        1 |
|        1 |
+----------+
719 rows in set (2.43 sec)
  SELECT COUNT(*) FROM osdial_agent_log WHERE DATE(event_time)='2015-11-01' GROUP BY lead_id;

I ran this query to get that data

Can someone help me to find the average for the above data.

Upvotes: 2

Views: 66

Answers (1)

Mateo Barahona
Mateo Barahona

Reputation: 1391

Use

SELECT AVG(total)
FROM (SELECT COUNT(*) AS total
FROM osdial_agent_log
WHERE DATE(event_time)='2015-11-01'
GROUP BY lead_id) t

Upvotes: 1

Related Questions