本文实例讲述了sql Server简单实现数据的日报和月报功能。分享给大家供大家参考,具体如下:
= '2009-01-01'
AND Order_Date<'2009-01-02'
/*AND Order_Date -- BETWEEN...AND相当于>=和<=
BETWEEN '2009-01-01'
AND '2009-01-02'*/
GROUP BY Cust_Name,120)
ORDER BY 2,1
--321. ORACLE 日报
--查询2009-01-01当天客户A1,TO_CHAR(Order_Date,'YYYY-MM-DD') Order_Date --方法一:转换成字符串类型
--,TRUNC(Order_Date) Order_Date --方法二:将时分秒信息截断,'A3')
AND Order_Date >= DATE'2009-01-01'
AND Order_Date= '2009-01-01'
AND Order_Date<'2009-02-01'
GROUP BY Cust_Name,1
--326,ORACLE
SELECT Cust_Name,'YYYY-MM') Order_YrMs --方法1
--,TRUNC(Order_Date,'MM') Order_Date--方法2,'A3')
AND Order_Date >= DATE'2009-01-01'
AND Order_Date方法1
--,'MM')--方法2
ORDER BY 2,1