derek.colley (7/23/2012)
I think this should do it:
DECLARE @n INT
SET @n = 1
WHILE @n <=31
BEGIN
SELECT ID, purchase_id, supp_add_mat_id,
mat_code,asset_no,
CASE WHEN DATEPART(dd, require_date) = @n THEN qty ELSE '0' END AS qty,
require_by,require_date,require_desc,
status,pr_detail_asset,scheduled
FROM...