please help me in aggregating set of marks from database. when i select the a particular department using dropdown listbox then the percentage of all the students has to be appear in the gridview who belongs to that branch in asp using c#.
for example.
it i select cse department then rollno,name,percentage has to be appear in the gridview. similarly other branches also .
my database is shown below.
----------------------------
| database table | |||||
| rollno | name | c | dbms | java | se |
| 1 | chiru | 80 | 89 | 78 | 88 |
| 2 | venu | 89 | 88 | 78 | 67 |
| 3 | naveen | 77 | 67 | 75 | 65 |
| rollno | name | percentage |
| 1 | chiru | 83.75 |
| 2 | venu | 80.5 |
| 3 | naveen | 71 |
thanks in advance


Jignesh TrivediRank #16 · 50.3K reputationPosted Jan 10, 2012, 8:58 PM EST
if your columns are static then
select rollno, name,((isnull(c,0) + isnull(dbms,0) + isnull(java,0),isnull(se,0))/4) as percentage from tableName.
hope this help.
as per me this is wrong database table design.
Ankit Shivnakr87 reputationPosted Jan 10, 2012, 9:04 PM EST
ChandraKant
Here is Solution for your problem plz find attachment
Anuja PawarRank #1,404 · 1.2K reputationPosted Jan 17, 2012, 3:28 AM EST
Try this
DECLARE @Average DECIMAL(5,2);
SELECT rollno,name,@Average=
(
COALESCE(c, 0) +
COALESCE(dbms, 0) +
COALESCE(java, 0)+
COALESCE(se,0)
)/4 FROM TableName
Hope it helps. Good Luck