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. RANKING IN VB.NET MYSQL

RANKING IN VB.NET MYSQL

Scheduled Pinned Locked Moved Database
csharpmysqlhelptutorial
9 Posts 3 Posters 0 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.
  • K Offline
    K Offline
    KipkoechE
    wrote on last edited by
    #1

    I have Records which are supposed to be assigned Position/Be Ranked e.g RegNo Marks Position 1 300 3 301 4 403 5 345 My Problem is How to rank/give position according to marks attained such that the results will be displayed as: RegNo Marks Position 1 300 4 3 301 3 4 403 1 5 345 2 using VB.NET MYSQL

    L 1 Reply Last reply
    0
    • K KipkoechE

      I have Records which are supposed to be assigned Position/Be Ranked e.g RegNo Marks Position 1 300 3 301 4 403 5 345 My Problem is How to rank/give position according to marks attained such that the results will be displayed as: RegNo Marks Position 1 300 4 3 301 3 4 403 1 5 345 2 using VB.NET MYSQL

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      KipkoechE wrote:

      how i will generate the position based on marks

      Probably by some calculation and sorting. But if you want some more useful help then please edit your question and explain the problem in proper detail. Also, is this really a Database question or a VB one?

      K 1 Reply Last reply
      0
      • L Lost User

        KipkoechE wrote:

        how i will generate the position based on marks

        Probably by some calculation and sorting. But if you want some more useful help then please edit your question and explain the problem in proper detail. Also, is this really a Database question or a VB one?

        K Offline
        K Offline
        KipkoechE
        wrote on last edited by
        #3

        I have Records which are supposed to be assigned Position/Be Ranked e.g RegNo Marks Position 1 300 3 301 4 403 5 345 My Problem is How to rank/give position according to marks attained such that the results will be displayed as: RegNo Marks Position 1 300 4 3 301 3 4 403 1 5 345 2 using VB.NET MYSQL

        L G 2 Replies Last reply
        0
        • K KipkoechE

          I have Records which are supposed to be assigned Position/Be Ranked e.g RegNo Marks Position 1 300 3 301 4 403 5 345 My Problem is How to rank/give position according to marks attained such that the results will be displayed as: RegNo Marks Position 1 300 4 3 301 3 4 403 1 5 345 2 using VB.NET MYSQL

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          You don't need the position field as that depends on the Marks. Just select your data using the ORDER BY clause[^] to sort them.

          K 1 Reply Last reply
          0
          • L Lost User

            You don't need the position field as that depends on the Marks. Just select your data using the ORDER BY clause[^] to sort them.

            K Offline
            K Offline
            KipkoechE
            wrote on last edited by
            #5

            but that will only sort it...What about the position

            1 Reply Last reply
            0
            • K KipkoechE

              I have Records which are supposed to be assigned Position/Be Ranked e.g RegNo Marks Position 1 300 3 301 4 403 5 345 My Problem is How to rank/give position according to marks attained such that the results will be displayed as: RegNo Marks Position 1 300 4 3 301 3 4 403 1 5 345 2 using VB.NET MYSQL

              G Offline
              G Offline
              GuyThiebaut
              wrote on last edited by
              #6

              A bit of google fu[^]gave me this:

              SELECT
              RegNo,
              Marks,
              @Position := @Position + 1 AS Position
              FROM results , (SELECT @Position:= 0) r
              ORDER BY Marks desc;

              “That which can be asserted without evidence, can be dismissed without evidence.”

              ― Christopher Hitchens

              K 1 Reply Last reply
              0
              • G GuyThiebaut

                A bit of google fu[^]gave me this:

                SELECT
                RegNo,
                Marks,
                @Position := @Position + 1 AS Position
                FROM results , (SELECT @Position:= 0) r
                ORDER BY Marks desc;

                “That which can be asserted without evidence, can be dismissed without evidence.”

                ― Christopher Hitchens

                K Offline
                K Offline
                KipkoechE
                wrote on last edited by
                #7

                it worked very well...thanks alot

                G 1 Reply Last reply
                0
                • K KipkoechE

                  it worked very well...thanks alot

                  G Offline
                  G Offline
                  GuyThiebaut
                  wrote on last edited by
                  #8

                  Glad it worked :thumbsup: I used the following google fu[^]

                  “That which can be asserted without evidence, can be dismissed without evidence.”

                  ― Christopher Hitchens

                  K 1 Reply Last reply
                  0
                  • G GuyThiebaut

                    Glad it worked :thumbsup: I used the following google fu[^]

                    “That which can be asserted without evidence, can be dismissed without evidence.”

                    ― Christopher Hitchens

                    K Offline
                    K Offline
                    KipkoechE
                    wrote on last edited by
                    #9

                    SELECT `RegNo`, Marks, @Position + 1 AS Position FROM results , (SELECT @Position:= 0) r ORDER BY Marks desc; It just needs that simple modification only

                    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