请问应该如何从原始表中用sql语句查出新表需要的数据? ------解决方案-------------------- select min(id) id,CONVERT(varchar(19),价格发布时间,121) 价格发布时间,sum(价格) 价格总计
from table group by CONVERT(varchar(19),价格发布时间,121) ------解决方案-------------------- 楼主试试,都可以的,
select min(id) id, min(createTime),sum(价格) 价格总计 from ( select * ,Convert(varchar(13),createTime,121)+ case
when datepart(mi,createTime)<=15 then 'aa'
when datepart(mi,createTime) between 16 and 30 then 'bb'
when datepart(mi,createTime) between 31 and 45 then 'cc'
when datepart(mi,createTime) between 46 and 59 then 'dd' end as date from table) a group by date