Index: app/helpers/queries_helper.rb =================================================================== --- app/helpers/queries_helper.rb (revision 11196) +++ app/helpers/queries_helper.rb (working copy) @@ -90,7 +90,7 @@ when 'Fixnum', 'Float' if column.name == :done_ratio progress_bar(value, :width => '80px') - elsif column.name == :spent_hours + elsif column.name == :spent_hours || column.name == :total_spent_hours sprintf "%.2f", value else h(value.to_s) Index: app/models/query.rb =================================================================== --- app/models/query.rb (revision 11196) +++ app/models/query.rb (working copy) @@ -470,8 +470,8 @@ @available_columns.each_with_index {|column, i| index = i if column.name == :estimated_hours} index = (index ? index + 1 : -1) # insert the column after estimated_hours or at the end - @available_columns.insert index, QueryColumn.new(:spent_hours, - :sortable => "(SELECT COALESCE(SUM(hours), 0) FROM #{TimeEntry.table_name} WHERE #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id)", + @available_columns.insert index, QueryColumn.new(:total_spent_hours, + :sortable => "(SELECT COALESCE(SUM(hours), 0) FROM #{TimeEntry.table_name} time_entry LEFT JOIN #{Issue.table_name} child_issue ON time_entry.issue_id = child_issue.id WHERE #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id OR child_issue.parent_id IS NOT NULL)", :default_order => 'desc', :caption => :label_spent_time )