Row sum query Archives - Tech Insights https://reactconf.org/category/row-sum-query/ Unveiling Tomorrow's Tech Today, Where Innovation Meets Insight Tue, 31 Jul 2012 11:31:00 +0000 en-US hourly 1 https://wordpress.org/?v=6.6.2 https://i0.wp.com/reactconf.org/wp-content/uploads/2023/11/cropped-reactconf.png?fit=32%2C32&ssl=1 Row sum query Archives - Tech Insights https://reactconf.org/category/row-sum-query/ 32 32 230003556 Row Sum in SQL https://reactconf.org/sql-case-statement/ https://reactconf.org/sql-case-statement/#respond Tue, 31 Jul 2012 11:31:00 +0000 http://www.sqlneed.com/2012/07/31/row-sum-in-sql/  How to Sum rows like  Sl No Name CN CA CG CO OS 1 AAA 60 76 45 61 242 2 AAB 45 56 46 72 219 3 AAC 67 …

The post Row Sum in SQL appeared first on Tech Insights.

]]>

 How to Sum rows like 
Sl No
Name
CN
CA
CG
CO
OS
1
AAA
60
76
45
61
242
2
AAB
45
56
46
72
219
3
AAC
67
45
47
84
243
4
AAD
89
87
87
91
354
5
AAE
76
90
67
51
284
6
AAF
56
56
66
41
219
7
AAG
45
45
56
44
190
A table used in this query
CREATE TABLE  “MARKS”
   (    “IDX” NUMBER,
        “NAME” VARCHAR2(100),
        “CN” NUMBER,
        “CA” NUMBER,
        “CG” NUMBER,
        “CO” NUMBER,
        “OS” NUMBER
   )
Oracle  SQL  Statement
SELECT NAME,
SUM(CASE WHEN idx=1 THEN  CN+CA+CG+CO+OS END) TOTAL
FROM MARKS
GROUP BY NAME
MS SQL Server  Statement
SELECT NAME,
SUM(CASE WHEN idx=1 THEN  CN+CA+CG+CO+OS  END) AS TOTAL
FROM MARKS
GROUP BY NAME

The post Row Sum in SQL appeared first on Tech Insights.

]]>
https://reactconf.org/sql-case-statement/feed/ 0 2233