By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE tbl(
Items varchar(15),
value1 int );
insert into tbl values
('First',50),
('First',50),
('Second',20),
('Second',20),
('Third',30);
select * from tbl;
Items | value1 |
---|---|
First | 50 |
First | 50 |
Second | 20 |
Second | 20 |
Third | 30 |
with cte as (
select Items,value1
from tbl
group by Items,value1
) select sum(value1) as tot_distinct_sum
from cte;
tot_distinct_sum |
---|
100 |