clear markdown compare help best fiddles feedback dbanow.uk a leap of faith?
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 1305636 fiddles created (20307 in the last week).

CREATE TABLE Calendar(cDate datetime, cDay int, cDayOfWeek int, cDayName varchar(20)); DECLARE @date date = '20180101'; WHILE @date <= '20180131' BEGIN INSERT INTO Calendar VALUES (@date, DAY(@date), DATEPART(weekday, @date), DATENAME(weekday, @date)); SET @date = DATEADD(day, 1, @date); END
31 rows affected
 hidden batch(es)


CREATE TABLE products(Productive int, Name char(3), Qty int, Created date); INSERT INTO products VALUES (111, 'ABC', 10, '1/10/2018'), (222, 'XYZ', 20, '1/10/2018'), (333, 'PQR', 30, '1/11/2018'), (444, 'MNC', 40, '1/15/2018'), (555, 'DEF', 50, '1/11/2018');
5 rows affected
 hidden batch(es)


SELECT c.cDate AS Created, COALESCE(Qty, 0) AS Qty FROM Calendar c LEFT JOIN (SELECT CONVERT(date, Created, 101) AS [Created], COUNT(Qty) AS [Qty] FROM products GROUP BY CONVERT(date, Created, 101)) p ON p.Created = c.cDate WHERE c.cDate >= (SELECT MIN(Created) FROM products) AND c.cDate <= (SELECT MAX(Created) FROM products);
Created Qty
10/01/2018 00:00:00 2
11/01/2018 00:00:00 2
12/01/2018 00:00:00 0
13/01/2018 00:00:00 0
14/01/2018 00:00:00 0
15/01/2018 00:00:00 1
 hidden batch(es)