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. Getting Top 5 from table of same category

Getting Top 5 from table of same category

Scheduled Pinned Locked Moved Database
helpdatabase
4 Posts 2 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.
  • H Offline
    H Offline
    honeyss
    wrote on last edited by
    #1

    Hi Friends, Let me Show u my table first and explain the problem later CategoryID CategoryName 1 MSDN 2 Google 3 Project 4 Code 5 Google 6 Project 7 MSDN 8 Google 9 Google 10 MSDN 11 Project 12 Project Now i need the top 2 categorynames from categorynames. I need the result as below CategoryID CategoryName 1 MSDN 7 MSDN 2 Google 5 Google 3 Project 6 Project 4 Code Please some one help me in getting this Query............ Thanks in Advance :)

    C 1 Reply Last reply
    0
    • H honeyss

      Hi Friends, Let me Show u my table first and explain the problem later CategoryID CategoryName 1 MSDN 2 Google 3 Project 4 Code 5 Google 6 Project 7 MSDN 8 Google 9 Google 10 MSDN 11 Project 12 Project Now i need the top 2 categorynames from categorynames. I need the result as below CategoryID CategoryName 1 MSDN 7 MSDN 2 Google 5 Google 3 Project 6 Project 4 Code Please some one help me in getting this Query............ Thanks in Advance :)

      C Offline
      C Offline
      ChandraRam
      wrote on last edited by
      #2

      Top 2 on what basis? What is the rule to define which way the records are sorted?

      H 1 Reply Last reply
      0
      • C ChandraRam

        Top 2 on what basis? What is the rule to define which way the records are sorted?

        H Offline
        H Offline
        honeyss
        wrote on last edited by
        #3

        Top2 based on each categoryname..........

        C 1 Reply Last reply
        0
        • H honeyss

          Top2 based on each categoryname..........

          C Offline
          C Offline
          ChandraRam
          wrote on last edited by
          #4

          Then the result you have shown does not match the data in the table.

          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