标签:des ar art 时间 sp on sql c har
$sql ="select sum(total),convert(char(10),createtime,120) createtime
from tb
group by convert(char(10),createtime,120)
order by sum(total) desc
";
$sql2 ="select sum(total) 总合, convert(varchar(7),createtime,120) as 月
from orders
group by convert(varchar(7),createtime,120)";
$sql3 = "select sum(total) as 总和 ,convert(char(10),createtime,120) createtime
from tb
where datepart(month,createtime)=datepart(month,getdate())
group by convert(char(10),createtime,120)
";
$sql4 =" select
convert(datetime, floor(convert(float, createtime))), sum(total)
from
orders
group by
floor(convert(float, createtime))
";
/*
上面的四种mssql 各有各的优点,各位可以试一下。
*/
标签:des ar art 时间 sp on sql c har
原文地址:http://www.cnblogs.com/zcwry/p/3929960.html