VB.NET MYSQL loop through records while adding
-
i have a table with students marks records which contains the data as follows: admno subjectGroup Exam subject marks 4719 GROUP I CAT-01 ENGLISH 45 4719 GROUP I CAT-01 KISWAHILI 78 4719 GROUP II CAT-01 CHEMISTRY 67 4719 GROUP II CAT-01 BIOLOGY 45 4719 GROUP II CAT-01 PHYSICS 45 4719 GROUP I CAT-01 MATHEMATICS 90 4720 GROUP I CAT-01 ENGLISH 67 4720 GROUP I CAT-01 KISWAHILI 61 4720 GROUP I CAT-01 MATHEMATICS 77 4721 GROUP I CAT-01 ENGLISH 81 4722 GROUP I CAT-01 KISWAHILI 62 4723 GROUP I CAT-01 ENGLISH 89 4724 GROUP I CAT-01 KISWAHILI 63 4726 GROUP I CAT-01 ENGLISH 78 4728 GROUP I CAT-01 ENGLISH 67 4730 GROUP I CAT-01 KISWAHILI 81 4734 GROUP I CAT-01 MATHEMATICS 56 i need to add marks belonging to a particular student(admno) based on the following criteria: for each student; 1. select 3 group I subjects 2. select the best 2 group II subjects ...kindly assist
-
i have a table with students marks records which contains the data as follows: admno subjectGroup Exam subject marks 4719 GROUP I CAT-01 ENGLISH 45 4719 GROUP I CAT-01 KISWAHILI 78 4719 GROUP II CAT-01 CHEMISTRY 67 4719 GROUP II CAT-01 BIOLOGY 45 4719 GROUP II CAT-01 PHYSICS 45 4719 GROUP I CAT-01 MATHEMATICS 90 4720 GROUP I CAT-01 ENGLISH 67 4720 GROUP I CAT-01 KISWAHILI 61 4720 GROUP I CAT-01 MATHEMATICS 77 4721 GROUP I CAT-01 ENGLISH 81 4722 GROUP I CAT-01 KISWAHILI 62 4723 GROUP I CAT-01 ENGLISH 89 4724 GROUP I CAT-01 KISWAHILI 63 4726 GROUP I CAT-01 ENGLISH 78 4728 GROUP I CAT-01 ENGLISH 67 4730 GROUP I CAT-01 KISWAHILI 81 4734 GROUP I CAT-01 MATHEMATICS 56 i need to add marks belonging to a particular student(admno) based on the following criteria: for each student; 1. select 3 group I subjects 2. select the best 2 group II subjects ...kindly assist
-
What is your question?
There are only 10 types of people in the world, those who understand binary and those who don't.
summing up marks per student(admno) based on the conditions given
-
i have a table with students marks records which contains the data as follows: admno subjectGroup Exam subject marks 4719 GROUP I CAT-01 ENGLISH 45 4719 GROUP I CAT-01 KISWAHILI 78 4719 GROUP II CAT-01 CHEMISTRY 67 4719 GROUP II CAT-01 BIOLOGY 45 4719 GROUP II CAT-01 PHYSICS 45 4719 GROUP I CAT-01 MATHEMATICS 90 4720 GROUP I CAT-01 ENGLISH 67 4720 GROUP I CAT-01 KISWAHILI 61 4720 GROUP I CAT-01 MATHEMATICS 77 4721 GROUP I CAT-01 ENGLISH 81 4722 GROUP I CAT-01 KISWAHILI 62 4723 GROUP I CAT-01 ENGLISH 89 4724 GROUP I CAT-01 KISWAHILI 63 4726 GROUP I CAT-01 ENGLISH 78 4728 GROUP I CAT-01 ENGLISH 67 4730 GROUP I CAT-01 KISWAHILI 81 4734 GROUP I CAT-01 MATHEMATICS 56 i need to add marks belonging to a particular student(admno) based on the following criteria: for each student; 1. select 3 group I subjects 2. select the best 2 group II subjects ...kindly assist
Use a select query with a where clause on the subject group to get the group 1 students limit the output to 3 records (TSQL has a TOP function, not sure about MySQL) For the second use the same query and change the where clause and the record limit. Add an order by on Marks to get the 2 records you need. This is a microsoft answer, technically correct but does not meet you requirements which I suspect should have included - give me the codz!
Never underestimate the power of human stupidity RAH
-
Use a select query with a where clause on the subject group to get the group 1 students limit the output to 3 records (TSQL has a TOP function, not sure about MySQL) For the second use the same query and change the where clause and the record limit. Add an order by on Marks to get the 2 records you need. This is a microsoft answer, technically correct but does not meet you requirements which I suspect should have included - give me the codz!
Never underestimate the power of human stupidity RAH
thanks for the answer....but that works well for a single student but for many students it add all marks of all students
-
thanks for the answer....but that works well for a single student but for many students it add all marks of all students
Ah my bad, I missed the add. You may need a nested select. First build your query to get the records you need and then wrap that in an aggregate query
select GroupID, sum(marks)
from(select GroupID, marks
From Table
Where Group = 'some code') X
group by GroupIDThe query X gets the records you need and the outer query aggregates those records.
Never underestimate the power of human stupidity RAH
-
Ah my bad, I missed the add. You may need a nested select. First build your query to get the records you need and then wrap that in an aggregate query
select GroupID, sum(marks)
from(select GroupID, marks
From Table
Where Group = 'some code') X
group by GroupIDThe query X gets the records you need and the outer query aggregates those records.
Never underestimate the power of human stupidity RAH
Thanks for the quick reply ...i have tried but could not really succeed. i managed the following SELECT `sAdmNo`,`SBGROUP`,SUM(AVG) FROM (select sAdmNo,SBGroup, AVG From (select sAdmNo,SBGroup, AVG FROM marks Where SBGroup = 'GROUP I' LIMIT 3)AS T Where SBGroup = 'GROUP II' LIMIT 2)AS TT GROUP BY sAdmNo ...kindly elaborate on how i can add from both groups