cris001
Starting Member
2 Posts |
Posted - 2014-11-22 : 10:10:28
|
Hello,I´m struggling to get the following query:Sales for the Last day of the month – sales for the last day of the previous monthGrouped by type and by monthCan anyone help please?Many thanks!Cris______________________________________DECLARE @sales TABLE(type VARCHAR(10) NOT NULL,date1 DATE NOT NULL,sales NUMERIC(10, 2) NOT NULL);INSERT INTO @sales(type, date1, sales)VALUES ('q', '20140408', 51),('q', '20140511', 3), ('q', '20140211', 3), ('q', '20140211', 5),('q', '20140516', 3), ('q', '20140608', 3), ('q', '20140715', 3), ('q', '20140712', 3),('q', '20140712', 3), ('q', '20140712', 3), ('q', '20140712', 4), ('q', '20140811', 3), ('q', '20140812', 1),('q', '20140815', 5),('q', '20140815', 6),('q', '20140815', 2),('q', '20140314', 7),('q', '20140824', 1),('q', '20140714', 24),('q', '20140714', 24),('x', '20140709', 25),('x', '20140710', 16),('x', '20140711', 36),('x', '20140712', 23),('x', '20140712', 35),('x', '20140715', 57),('c', '20140712', 97),('c', '20140715', 71) |
|