sql - sum by rows (include all columns) in Oracle -
i have structure of table
----------------------------------------------------------------- id-prod | monday | tuesday | wednesday | thursday | friday |.... ----------------------------------------------------------------- 012 213 879 516 213 435 013 953 837 361 862 014 123 583 879 519 573 015 963 016 798
id-prod primary key, i sum values each product example
--------------------------------------------------------------------------------------- id-prod | monday | tuesday | wednesday | thursday | friday |....| total --------------------------------------------------------------------------------------- 012 213 879 516 213 435 213+879+516+213+435 013 953 837 361 862 ..... 014 123 583 879 519 573 ..... 015 963 016 798
thanks
select t.*, coalesce(monday, 0) + coalesce(tuesday, 0) + coalesce(wednesday, 0) + coalesce(thursday, 0) + coalesce(friday, 0) total mytable t
Comments
Post a Comment