M myhby Unregistered / Unconfirmed GUEST, unregistred user! 2008-02-23 #1 例如:表A(FDate,Num) FDAte这日期型,按求按年月对NUM进行分类汇总。
D dcx0026 Unregistered / Unconfirmed GUEST, unregistred user! 2008-02-25 #2 SELECT Format(FDate,"yyyy-mm"), Sum(Num) AS TotalNum FROM A GROUP BY Format(FDate,"yyyy-mm"),
Y yanfeng1001 Unregistered / Unconfirmed GUEST, unregistred user! 2008-02-27 #4 SELECT left(FDate,7), Sum(Num) AS TotalNum FROM A GROUP BY left(FDate,7)
L lanyaoshi Unregistered / Unconfirmed GUEST, unregistred user! 2008-02-27 #5 FDate Num 2007-1-1 1 2007-1-2 2 2007-2-2 1 2008-1-1 3 2008-2-1 2 2008-2-3 4 SELECT SUM(Num) AS 汇总, YEAR(FDate) AS 年, Month(FDate) AS 月 FROM 表A GROUP BY YEAR(FDate), Month(FDate); 查询结果: 汇总 年 月 3 2007 1 1 2007 2 3 2008 1 6 2008 2
FDate Num 2007-1-1 1 2007-1-2 2 2007-2-2 1 2008-1-1 3 2008-2-1 2 2008-2-3 4 SELECT SUM(Num) AS 汇总, YEAR(FDate) AS 年, Month(FDate) AS 月 FROM 表A GROUP BY YEAR(FDate), Month(FDate); 查询结果: 汇总 年 月 3 2007 1 1 2007 2 3 2008 1 6 2008 2
A abcdman Unregistered / Unconfirmed GUEST, unregistred user! 2008-02-27 #7 我也是用yanfeng1001的方法做的,哈哈,不过发现lanyaoshi的方法更科学些,支持lanyaoshi方法!!