Reputation: 679
I have ordinary sql table in MySql database. I have approximately 150 columns and I would like to compute average of rows of this table. I am going to do this in c#.
So I would like to do somethig like this:
private void button1_Click(object sender, EventArgs e) {
for(int i=1; i<=rowCount;i++){
string query="SELECT AVG(Column1, Column2, ... Column150) FROM mytable WHERE ID="+i;
MySqlCommand cmd = new MySqlCommand(query1, connect);
// and here I will save partial results to array
}
}
Is something like this posible? Thx
Upvotes: 0
Views: 156
Reputation: 2857
No, it won't work this way. Average is a function above a column, not above a row.
Here, you can try something like:
SELECT (Column1 + Column2 + ... Column150)/150.0 FROM mytable WHERE ID="+i
Upvotes: 1