Thank you to you both for responding. I'll attempt to provide a little more clarification. This image displays, in essence, what I've already got accomplished.
Basically, if Recordable_Injury column is not empty, it get recorded as a 1 in the RIF column. If Recordable_Injury contains either "Lost Time" or "Fatality", it gets recorded as a 1 in the LTIR column, and finally, if PSET1_2 is not empty it gets recorded as a 1 in the PSER column.
These results are grouped by 1) the first day of the month for 2) each Operating_Area.
My sql Create View code adds additional groupings to the Operating_Area column. Essentially, AreaA and AreaB, for example could be a part of Group A and, or Group B etc.
Finally harishgg1, what I'm trying to do is get a growing number each month until the end of each year, for each operating_Area. If there were 2 RIFs in January and 3 in February, I'll see 5 beside 02/01/2022 (for that particular Operating_Area)
Here is the code I'm using. Again, it's repeated quite a bit for the different groups.
CREATE VIEW [dbo].[EHS_Reporting_Records_Count_Combined]
AS
SELECT
DATEFROMPARTS(YEAR([Incident_Date]), MONTH([Incident_Date]), 1) AS [Date],
[Operating_Area],
COUNT(CASE WHEN [Recordable_Injury] IS NOT NULL THEN 1 END) AS [RIF],
COUNT(CASE WHEN [Recordable_Injury] IN ('Lost Time', 'Fatality') THEN 1 END) AS [LTIR],
COUNT(CASE WHEN [PSET1_2] IS NOT NULL THEN 1 END) AS [PSER]
FROM [dbo].[EHS_Reporting_Records]
GROUP BY
DATEFROMPARTS(YEAR([Incident_Date]), MONTH([Incident_Date]), 1),
[Operating_Area]
--Group A
UNION ALL
SELECT
DATEFROMPARTS(YEAR([Incident_Date]), MONTH([Incident_Date]), 1) AS [Date],
'Group A' AS [Operating_Area],
COUNT(CASE WHEN [Recordable_Injury] IS NOT NULL THEN 1 END) AS [RIF],
COUNT(CASE WHEN [Recordable_Injury] IN ('Lost Time', 'Fatality') THEN 1 END) AS [LTIR],
COUNT(CASE WHEN [PSET1_2] IS NOT NULL THEN 1 END) AS [PSER]
FROM [dbo].[EHS_Reporting_Records]
WHERE [Operating_Area] IN ('AreaA', 'AreaC', 'AreaD', 'AreaE', 'AreaF', 'AreaG', 'AreaB', 'AreaH', 'AreaI', 'AreaJ', 'AreaK')
GROUP BY
DATEFROMPARTS(YEAR([Incident_Date]), MONTH([Incident_Date]), 1)
--Group B
UNION ALL
SELECT
DATEFROMPARTS(YEAR([Incident_Date]), MONTH([Incident_Date]), 1) AS [Date],
'Group B' AS [Operating_Area],
COUNT(CASE WHEN [Recordable_Injury] IS NOT NULL THEN 1 END) AS [RIF],
COUNT(CASE WHEN [Recordable_Injury] IN ('Lost Time', 'Fatality') THEN 1 END) AS [LTIR],
COUNT(CASE WHEN [PSET1_2] IS NOT NULL THEN 1 END) AS [PSER]
FROM [dbo].[EHS_Reporting_Records]
WHERE [Operating_Area] IN ('AreaA', 'AreaC', 'AreaD', 'AreaE', 'AreaF', 'AreaG', 'AreaB', 'AreaH', 'AreaJ', 'AreaK')
GROUP BY
DATEFROMPARTS(YEAR([Incident_Date]), MONTH([Incident_Date]), 1)
--Group C
UNION ALL
SELECT
DATEFROMPARTS(YEAR([Incident_Date]), MONTH([Incident_Date]), 1) AS [Date],
'Group C' AS [Operating_Area],
COUNT(CASE WHEN [Recordable_Injury] IS NOT NULL THEN 1 END) AS [RIF],
COUNT(CASE WHEN [Recordable_Injury] IN ('Lost Time', 'Fatality') THEN 1 END) AS [LTIR],
COUNT(CASE WHEN [PSET1_2] IS NOT NULL THEN 1 END) AS [PSER]
FROM [dbo].[EHS_Reporting_Records]
WHERE [Operating_Area] IN ('AreaC', 'AreaD', 'AreaE', 'AreaG', 'AreaH', 'AreaJ', 'AreaK')
GROUP BY
DATEFROMPARTS(YEAR([Incident_Date]), MONTH([Incident_Date]), 1)
--Group D
UNION ALL
SELECT
DATEFROMPARTS(YEAR([Incident_Date]), MONTH([Incident_Date]), 1) AS [Date],
'Group D' AS [Operating_Area],
COUNT(CASE WHEN [Recordable_Injury] IS NOT NULL THEN 1 END) AS [RIF],
COUNT(CASE WHEN [Recordable_Injury] IN ('Lost Time', 'Fatality') THEN 1 END) AS [LTIR],
COUNT(CASE WHEN [PSET1_2] IS NOT NULL THEN 1 END) AS [PSER]
FROM [dbo].[EHS_Reporting_Records]
WHERE [Operating_Area] IN ('AreaC', 'AreaD', 'AreaE', 'AreaG', 'AreaH', 'AreaK')
GROUP BY
DATEFROMPARTS(YEAR([Incident_Date]), MONTH([Incident_Date]), 1)
--Group F
UNION ALL
SELECT
DATEFROMPARTS(YEAR([Incident_Date]), MONTH([Incident_Date]), 1) AS [Date],
'Group F' AS [Operating_Area],
COUNT(CASE WHEN [Recordable_Injury] IS NOT NULL THEN 1 END) AS [RIF],
COUNT(CASE WHEN [Recordable_Injury] IN ('Lost Time', 'Fatality') THEN 1 END) AS [LTIR],
COUNT(CASE WHEN [PSET1_2] IS NOT NULL THEN 1 END) AS [PSER]
FROM [dbo].[EHS_Reporting_Records]
WHERE [Operating_Area] IN ('AreaA', 'AreaF', 'AreaB')
GROUP BY
DATEFROMPARTS(YEAR([Incident_Date]), MONTH([Incident_Date]), 1)
--Group E
UNION ALL
SELECT
DATEFROMPARTS(YEAR([Incident_Date]), MONTH([Incident_Date]), 1) AS [Date],
'Group E' AS [Operating_Area],
COUNT(CASE WHEN [Recordable_Injury] IS NOT NULL THEN 1 END) AS [RIF],
COUNT(CASE WHEN [Recordable_Injury] IN ('Lost Time', 'Fatality') THEN 1 END) AS [LTIR],
COUNT(CASE WHEN [PSET1_2] IS NOT NULL THEN 1 END) AS [PSER]
FROM [dbo].[EHS_Reporting_Records]
WHERE [Operating_Area] IN ('AreaA', 'AreaB')
GROUP BY
DATEFROMPARTS(YEAR([Incident_Date]), MONTH([Incident_Date]), 1)