日期:2014-05-18  浏览次数:20594 次

问一个查询语句,谢谢
mysql的查询语句,可以把结果以2007-03类似的格式查询出来。。
select   DATE_FORMAT(MonDate, '%Y-%m ')   as   anaMonth   from   mon_log   where   GroupNo=?   group   by   anaMonth   order   by   anaMonth   desc;

我想问同样的要求,在sql   server2000里面怎么写??

------解决方案--------------------
select convert(varchar(7),getdate(),120)
------解决方案--------------------
select convert(varchar(7),时间字段,120) as 时间字段 , max , sum ...
from tb
group by convert(varchar(7),时间字段,120)
------解决方案--------------------
120 121兩種格式都可以

Select Convert(Varchar(7), GetDate(), 120)
Select Convert(Varchar(7), GetDate(), 121)
--Result
/*
2007-03
*/
------解决方案--------------------
你的語句可以這麼寫

select Convert(Varchar(7), GetDate(), 121) as anaMonth from mon_log where GroupNo=? group by Convert(Varchar(7), GetDate(), 121) order by anaMonth desc