SQL Server provides daily and monthly data reports, and SQL monthly data reports.
This example describes how to use SQL Server to implement daily and monthly data reports. We will share this with you for your reference. The details are as follows:
-- 320, SQL SERVER daily -- query the order quantity of customers A1, A2, A3 on SELECT Cust_Name, CONVERT (CHAR (10), Order_Date, 120) Order_Date, SUM (Qty) qtyFROM Orders_BigWHERE 1 = 1 AND Cust_Name IN ('a1', 'a2 ', 'a3 ') AND Order_Date> = '2014-01-01 'AND Order_Date <'2014-01-02'/* AND Order_Date --... AND is equivalent to> = AND <= BETWEEN '2014-01-01 'AND '2014-01-02' */group by Cust_Name, CONVERT (CHAR (10), Order_Date, 2009) order by 2, 1--321. ORACLE daily -- query the customer A1, A2, A3 order quantity SELECT Cust_Name, TO_CHAR (Order_Date, 'yyyy-MM-DD ') Order_Date -- Method 1: Convert to string type --, TRUNC (Order_Date) Order_Date -- Method 2: TRUNC (Order_Date) truncation of the time AND second information, SUM (Qty) QtyFROM Orders_BigWHERE 1 = 1 AND Cust_Name IN ('a1', 'a2 ', 'a3 ') AND Order_Date> = DATE '2014-01-01 'AND Order_Date <DATE '2014-01-02' group by Cust_Name, TO_CHAR (Order_Date, 'yyyy-MM-DD ') -- Method 1 --, TRUNC (Order_Date) -- method 2 order by 2, clerk, SQL SERVER Monthly Report SELECT Cust_Name, CONVERT (CHAR (7), Order_Date, 120) Order_YrMs, CAST (CONVERT (CHAR (7), Order_Date, 120) + '-01' as datetime) Order_Date, SUM (Qty) QtyFROM Orders_BigWHERE 1 = 1 AND Cust_Name IN ('a1 ', 'a2 ', 'a3') AND Order_Date> = '2017-01-01 'AND Order_Date <'2017-02-01' group by Cust_Name, CONVERT (CHAR (7), Order_Date, 2009) order by 2, 1--326, ORACLESELECT Cust_Name, TO_CHAR (Order_Date, 'yyyy-mm') Order_YrMs -- Method 1 --, TRUNC (Order_Date, 'mm') Order_Date -- method 2, SUM (Qty) QtyFROM Orders_BigWHERE 1 = 1 AND Cust_Name IN ('a1', 'a2 ', 'a3 ') AND Order_Date> = DATE '2014-01-01 'AND Order_Date <DATE '2014-02-01' group by Cust_Name, TO_CHAR (Order_Date, 'yyyy-mm') -- Method 1 --, TRUNC (Order_Date, 'mm') -- method 2 order by 2, 1
I hope this article will help you design SQL Server database programs.