I want to show each month, January - December and show a total sale amount for that each month. I can not figure out how to have the month display if there is no data in the table for it. This is my DDL
CREATE TABLE PrevYear (
[EmployeeNumber] char(8) NOT NULL,
[SaleAmount] int DEFAULT NULL,
[SaleDate] date NOT NULL,
[EmployeeName] char(17) NOT NULL
);
CREATE TABLE CurrentYear (
[EmployeeNumber] char(8) NOT NULL,
[SaleAmount] int DEFAULT NULL,
[SaleDate] date NOT NULL,
[EmployeeName] char(17) NOT NULL
);
INSERT INTO CurrentYear
VALUES ('ea12', '100', '2019-01-10', 'Sam Smith');
INSERT INTO CurrentYear
VALUES ('ea12', '199', '2019-01-13', 'Sam Smith');
INSERT INTO CurrentYear
VALUES ('ea12', '100', '2019-03-01', 'Sam Smith');
INSERT INTO CurrentYear
VALUES ('ls22', '100', '2019-05-01', 'Sam Smith');
INSERT INTO PrevYear
VALUES ('ea12', '100', '2018-01-10', 'Sam Smith');
INSERT INTO PrevYear
VALUES ('ea12', '199', '2018-01-13', 'Sam Smith');
INSERT INTO PrevYear
VALUES ('ea12', '100', '2018-03-01', 'Sam Smith');
INSERT INTO PrevYear
VALUES ('ls22', '100', '2018-05-01', 'Sam Smith');
My desired output is:(please not the $ amount is just a placeholder)
Jan 18 $1
Jan 19 $1
Feb 18 $1
Feb 19 $1
Mar 18 $1
Mar 19 $1
Apr 18 $1
Apr 19 $1
May 18 $1
May 19 $1
Jun 18 $1
Jun 19 $1
Jul 18 $1
Jul 19 $1
Aug 18 $1
Aug 19 $1
Sep 18 $1
Sep 19 $0
Oct 18 $1
Oct 19 $0
Nov 18 $1
Nov 19 $0
Dec 18 $1
Dec 19 $0