computed column with aggregate function

Posted by Kindson on Stack Overflow See other posts from Stack Overflow or by Kindson
Published on 2010-05-27T08:40:30Z Indexed on 2010/05/27 10:01 UTC
Read the original article Hit count: 178

Filed under:

I have seven columns in my table: hours, weight, status, total_hours, total_weight and percentage

total_weight = weight where status = 'X'
total_hours = hours where status = 'X'
percentage = total_hours/sum(weight)

sum(weight) is an aggregate function

I would like to specify formula to generate the three computed columns. What do i do?

© Stack Overflow or respective owner

Related posts about sql-server