I have a doubt regarding MySQL. I have a table where it has some columns. I have to make a calculation to each entry using the entry itself. presently I am kind of using the following way for each entry ...

select ((count(b)*10)/sum(a)) as AvgT from Kross where b = 'ABC';

Is there anyway to do it for all the entries without using WHERE??? May be using a loop for every entry in the column b or something like that ...

有帮助吗?

解决方案

Try: group by instead of where.

select ((count(b)*10)/sum(a)) as AvgT from Kross group by b
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top