View Single Post

   
  #7 (permalink)  
Old 02-28-2008, 10:26 AM
damezumari
 
Posts: n/a
Default Re: Total without and with a condition

Above is shown how to add up numbers with and without a condition
($ask_answers_condition) and give the results in one row.

Here is my attempt to do the same for max, min, and average of time
records:

SEC_TO_TIME(avg(TIME_TO_SEC(ask_answers.timetaken) )) as average,
max(ask_answers.timetaken) as max,
min(ask_answers.timetaken) as min,
SEC_TO_TIME(avg(TIME_TO_SEC(if('.$ask_answers_cond ition.',
ask_answers.timetaken, null)))) as condaverage,
min(if('.$ask_answers_condition.', ask_answers.timetaken,
"99999:59:59")) as condmin,
max(if('.$ask_answers_condition.', ask_answers.timetaken,
"00:00:00")) as condmax

It seems to work!

Regards,

Jan Nordgreen

Reply With Quote