S Ringne - 1 year ago 87

MySQL Question

i have a table:

`+-----------------+-----------+`

| CategoryCount | frequency |

+-----------------+-----------+

| 0 | 123 |

| 12 | 234 |

| 15 | 456 |

| 0 | 678 |

| 25 | 890 |

| 0 | 145 |

+-----------------+-----------+

it has 300 rows

I want to find total no. of count,where the frequency is less than 75%

i am writing this query:

`select sum(CategoryCount)`

from Session_category_analysis

where frequency/sum(frequency) < 0.75;

but i am getting error as

ERROR 1111 (HY000):Invalid use of group function

i also tried using this query:

`select CategoryCount , frequency`

from Session_category_analysis

where frequency/sum(frequency) < 0.75

group by CategoryCount ;

ERROR 1111 (HY000): Invalid use of group function

also this query, but failed

`select CategoryCount from Session_category_analysis`

where(select frequency/sum(frequency)

from Session_category_analysis

where frequency/sum(frequency) < 0.75

);

ERROR 1111 (HY000): Invalid use of group function

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

```
select sum(CategoryCount)
from Session_category_analysis
where (frequency * 100 / (select sum(frequency) from Session_category_analysis)) < 75
```

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**