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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Do SQL server have some functions as like "Select bottom"?

Do SQL server have some functions as like "Select bottom"?

Scheduled Pinned Locked Moved Database
databasesql-serversysadminquestion
4 Posts 4 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.
  • C Offline
    C Offline
    caiguosen
    wrote on last edited by
    #1

    I have thousands of tables, and the fields are always ordered by date, and i want to select bottom 60 from all the tables. I know I can realize this function by following statement: select top 60 from table order by date desc but I don't want to use "order by", all my data is sorted and it will waste my time. so can I get the bottom 60 record from the db? Is there any function like "select bottom 60"?

    I M D 3 Replies Last reply
    0
    • C caiguosen

      I have thousands of tables, and the fields are always ordered by date, and i want to select bottom 60 from all the tables. I know I can realize this function by following statement: select top 60 from table order by date desc but I don't want to use "order by", all my data is sorted and it will waste my time. so can I get the bottom 60 record from the db? Is there any function like "select bottom 60"?

      I Offline
      I Offline
      i j russell
      wrote on last edited by
      #2

      Yes, SELECT TOP 60 FROM Table ORDER BY date DESC. If it is good enough for every database professional on every database platform, then I would suggest that it isn't as bad as seem to think! If I understand what you mean by 'sorted' then I suggest that you find an article/book about how databases store data; I think that you will be very surprised.

      1 Reply Last reply
      0
      • C caiguosen

        I have thousands of tables, and the fields are always ordered by date, and i want to select bottom 60 from all the tables. I know I can realize this function by following statement: select top 60 from table order by date desc but I don't want to use "order by", all my data is sorted and it will waste my time. so can I get the bottom 60 record from the db? Is there any function like "select bottom 60"?

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

        caiguosen wrote:

        but I don't want to use "order by", all my data is sorted and it will waste my time.

        Then get a different job and don't waste our time.

        Never underestimate the power of human stupidity RAH

        1 Reply Last reply
        0
        • C caiguosen

          I have thousands of tables, and the fields are always ordered by date, and i want to select bottom 60 from all the tables. I know I can realize this function by following statement: select top 60 from table order by date desc but I don't want to use "order by", all my data is sorted and it will waste my time. so can I get the bottom 60 record from the db? Is there any function like "select bottom 60"?

          D Offline
          D Offline
          dan sh
          wrote on last edited by
          #4

          If you are already ordering the fields and know you need records from end, why not store them the opposite way as current. I mean order records from current to older dates. In that case all you will need is to get top xx records from the table. This should have been thought while designing database IMHO.

          "No matter how many fish in the sea; it will be so empty without me." - From song "Without me" by Eminem

          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