I want to take average of multiple columns such that if there is null value then ignore that and take remaining value as take average.
For example if I have 10,NULL as values then I want 10 as average, I don't want the null value to be considered as 0 and then take average as 10+0 -> 5, I want the average to be 10.
This is a dummy table, I have multiple columns like Month1.... Month 1000 and I don't want to hardcode any values while calculating average by dividing the number of column.
My output from this query is wrong:
CREATE TABLE Dummy_tab
(
empid int,
Month1 int,
Month2 int,
Month3 int,
);
INSERT INTO Dummy_tab
VALUES (1, NULL,10, 20), (2, NULL,NULL, 20), (3, 10,20, 30);
SELECT
empid,
AVG(Month1 + Month2 + Month3)
FROM
Dummy_tab
GROUP BY
empid
Snippet for the desired output along with what my output is coming
