select count(a.orderID), avg(a.SaveDateCount), avg(a.SaveTimeCount) from (select orderID, count(Save_Date) SaveDateCount, count(Save_Time) SaveTimeCount from market_log) a