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. Without using order by

Without using order by

Scheduled Pinned Locked Moved Database
career
7 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.
  • V Offline
    V Offline
    vimal_yet
    wrote on last edited by
    #1

    Hi, i have a table of employee details where i have empno, name, salary. i need to select the salary from the table in the descending order. the condition here is that I should not use order by clause.

    If U Get Errors U Will Learn If U Don't Get Errors U Have Learnt

    K G P 4 Replies Last reply
    0
    • V vimal_yet

      Hi, i have a table of employee details where i have empno, name, salary. i need to select the salary from the table in the descending order. the condition here is that I should not use order by clause.

      If U Get Errors U Will Learn If U Don't Get Errors U Have Learnt

      K Offline
      K Offline
      Krish KP
      wrote on last edited by
      #2

      Are you trying to do this in an inline query. what is your actual requirement.

      Regards KP

      V 1 Reply Last reply
      0
      • K Krish KP

        Are you trying to do this in an inline query. what is your actual requirement.

        Regards KP

        V Offline
        V Offline
        vimal_yet
        wrote on last edited by
        #3

        u can use inline query . but my constraint is not to use order by clause

        If U Get Errors U Will Learn If U Don't Get Errors U Have Learnt

        1 Reply Last reply
        0
        • V vimal_yet

          Hi, i have a table of employee details where i have empno, name, salary. i need to select the salary from the table in the descending order. the condition here is that I should not use order by clause.

          If U Get Errors U Will Learn If U Don't Get Errors U Have Learnt

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

          I could never see any reason for ever not using an order by clause to sort the output of a query. The only other alternative I can think of is by setting the salary to be the primary key on a clustered index and see if that works. This would of course be very bad design methodology as the empno field would make better sense as the primary key. I would be more than happy to be proved wrong and am interested in what solution you come to. Regards Guy

          You always pass failure on the way to success.
          1 Reply Last reply
          0
          • V vimal_yet

            Hi, i have a table of employee details where i have empno, name, salary. i need to select the salary from the table in the descending order. the condition here is that I should not use order by clause.

            If U Get Errors U Will Learn If U Don't Get Errors U Have Learnt

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

            Try something like this: CREATE TABLE #MyTempTable (salary decimal(28,12)) INSERT INTO #MyTempTable SELECT salary FROM employeedetails GROUP BY salary CREATE INDEX salary ON #MyTempTable (salary DESC) SELECT * FROM #MyTempTable Regards Guy

            You always pass failure on the way to success.

            modified on Friday, December 28, 2007 6:15:09 AM

            V 1 Reply Last reply
            0
            • V vimal_yet

              Hi, i have a table of employee details where i have empno, name, salary. i need to select the salary from the table in the descending order. the condition here is that I should not use order by clause.

              If U Get Errors U Will Learn If U Don't Get Errors U Have Learnt

              P Offline
              P Offline
              Pete OHanlon
              wrote on last edited by
              #6

              This sounds very suspiciously like homework to me. We don't actually do your homework for you, so you'd better let us know what you've tried beforehand.

              Deja View - the feeling that you've seen this post before.

              My blog | My articles

              1 Reply Last reply
              0
              • G GuyThiebaut

                Try something like this: CREATE TABLE #MyTempTable (salary decimal(28,12)) INSERT INTO #MyTempTable SELECT salary FROM employeedetails GROUP BY salary CREATE INDEX salary ON #MyTempTable (salary DESC) SELECT * FROM #MyTempTable Regards Guy

                You always pass failure on the way to success.

                modified on Friday, December 28, 2007 6:15:09 AM

                V Offline
                V Offline
                vimal_yet
                wrote on last edited by
                #7

                Thanks Guy.... It sounds good.and this was the one i guessed....

                If U Get Errors U Will Learn If U Don't Get Errors U Have Learnt

                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