Domanda

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 ...

È stato utile?

Soluzione

Try: group by instead of where.

select ((count(b)*10)/sum(a)) as AvgT from Kross group by b
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top