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. How to get top n records

How to get top n records

Scheduled Pinned Locked Moved Database
databasetutorialquestion
2 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.
  • F Offline
    F Offline
    FishiFishi
    wrote on last edited by
    #1

    Hi All i want to get top 5 records from the table. what would be the query? Regards Qaiser

    T 1 Reply Last reply
    0
    • F FishiFishi

      Hi All i want to get top 5 records from the table. what would be the query? Regards Qaiser

      T Offline
      T Offline
      Tirthadip
      wrote on last edited by
      #2

      Returning only the first N records in a SQL query differs quite a bit between database platforms. Here's some samples: Microsoft SQL Server SELECT TOP 10 column FROM table PostgreSQL and MySQL SELECT column FROM table LIMIT 10 Oracle SELECT column FROM table WHERE ROWNUM <= 10 Sybase SET rowcount 10 SELECT column FROM table Firebird SELECT FIRST 10 column FROM table

      Tirtha Do not go where the path may lead, go instead where there is no path and leave a trail. Author: Ralph Waldo Emerson (1803-82), American writer, philosopher, poet, essayist

      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