By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
select version();
version() |
---|
5.7.39 |
create table SAMPLE(ID INT, SAL INT);
INSERT INTO SAMPLE VALUES(1,1000);
INSERT INTO SAMPLE VALUES(1,2000);
INSERT INTO SAMPLE VALUES(2,3000);
INSERT INTO SAMPLE VALUES(2,1000);
INSERT INTO SAMPLE VALUES(3,NULL);
select ID,IFNULL(SUM(SAL),'N/A') AS SUM_RESULT FROM SAMPLE GROUP BY ID
ID | SUM_RESULT |
---|---|
1 | 3000 |
2 | 4000 |
3 | N/A |