Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. VB.NET MYSQL loop through records while adding

VB.NET MYSQL loop through records while adding

Scheduled Pinned Locked Moved Database
csharpmysqlgame-dev
7 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Pauls Pauls
    wrote on last edited by
    #1

    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

    Z M 2 Replies Last reply
    0
    • P Pauls Pauls

      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

      Z Offline
      Z Offline
      ZurdoDev
      wrote on last edited by
      #2

      What is your question?

      There are only 10 types of people in the world, those who understand binary and those who don't.

      P 1 Reply Last reply
      0
      • Z ZurdoDev

        What is your question?

        There are only 10 types of people in the world, those who understand binary and those who don't.

        P Offline
        P Offline
        Pauls Pauls
        wrote on last edited by
        #3

        summing up marks per student(admno) based on the conditions given

        1 Reply Last reply
        0
        • P Pauls Pauls

          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

          M Offline
          M Offline
          Mycroft Holmes
          wrote on last edited by
          #4

          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

          P 1 Reply Last reply
          0
          • M Mycroft Holmes

            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

            P Offline
            P Offline
            Pauls Pauls
            wrote on last edited by
            #5

            thanks for the answer....but that works well for a single student but for many students it add all marks of all students

            M 1 Reply Last reply
            0
            • P Pauls Pauls

              thanks for the answer....but that works well for a single student but for many students it add all marks of all students

              M Offline
              M Offline
              Mycroft Holmes
              wrote on last edited by
              #6

              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 GroupID

              The query X gets the records you need and the outer query aggregates those records.

              Never underestimate the power of human stupidity RAH

              P 1 Reply Last reply
              0
              • M Mycroft Holmes

                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 GroupID

                The query X gets the records you need and the outer query aggregates those records.

                Never underestimate the power of human stupidity RAH

                P Offline
                P Offline
                Pauls Pauls
                wrote on last edited by
                #7

                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

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups