select to_Days(from_unixtime(mdate)) as aday,
round(from_unixtime(o.mdate)/1000000)  as SalesDate,  
sum(order_total) as SalesValue
from <@PREFIX>vm_orders
where from_unixtime(mdate) <= %s
and from_unixtime(mdate) >= %s
group by to_Days(from_unixtime(mdate))
order by mdate desc