Msg#: 4517671 posted 1:04 am on Nov 10, 2012 (gmt 0)
Ok, I have some numeric columns, and I want to establish and average for them. e.g. col 1 value = 4 col 2 value = 7 col 3 value = 3 col 4 value = 9 I want to be able to create (4+7+3+9)/4, as another column in a query. Then I want to use this number as for ORDER BY for another table. With the numbers table there is another column that has an id relating to this other table. I really can't get my head around this. It's hard enough to explain. Let me know if you need more help in explaining.
Msg#: 4517671 posted 9:49 am on Nov 10, 2012 (gmt 0)
1) alter table X add column average_float float(6,2) <- or simlar 2) update X set average_float = (col1+col2+col3+col4)/4; 3) in your Y table which references X: select * from Y (.....) order by (select average_float from X where X.id = Y.id) desc