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. Arrange database Column entries by ascending order. Pin

Arrange database Column entries by ascending order. Pin

Scheduled Pinned Locked Moved Database
databasehelpquestion
4 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.
  • J Offline
    J Offline
    jeshra279
    wrote on last edited by
    #1

    Hi All, I have a SQL database column "ID", in which I added one by one entries as 2,5,6,1,8... randomely. I want to arrange these entries in Ascending order so that in datagridview it get displayed in order 1,2,3,4... like this. Can someone help me on this?

    A N 2 Replies Last reply
    0
    • J jeshra279

      Hi All, I have a SQL database column "ID", in which I added one by one entries as 2,5,6,1,8... randomely. I want to arrange these entries in Ascending order so that in datagridview it get displayed in order 1,2,3,4... like this. Can someone help me on this?

      A Offline
      A Offline
      Ashfield
      wrote on last edited by
      #2

      Ever tried the ORDER BY clause?

      Bob Ashfield Consultants Ltd Proud to be a 2009 Code Project MVP

      1 Reply Last reply
      0
      • J jeshra279

        Hi All, I have a SQL database column "ID", in which I added one by one entries as 2,5,6,1,8... randomely. I want to arrange these entries in Ascending order so that in datagridview it get displayed in order 1,2,3,4... like this. Can someone help me on this?

        N Offline
        N Offline
        Niladri_Biswas
        wrote on last edited by
        #3

        Try this

        declare @t table(id int)
        insert into @t
        select 3 union all
        select 1 union all
        select 5 union all
        select 4 union all
        select 2

        Query:

        select * from @t order by id

        Output: id

        1
        2
        3
        4
        5

        :)

        Niladri Biswas

        J 1 Reply Last reply
        0
        • N Niladri_Biswas

          Try this

          declare @t table(id int)
          insert into @t
          select 3 union all
          select 1 union all
          select 5 union all
          select 4 union all
          select 2

          Query:

          select * from @t order by id

          Output: id

          1
          2
          3
          4
          5

          :)

          Niladri Biswas

          J Offline
          J Offline
          jeshra279
          wrote on last edited by
          #4

          I have already inserted "EmpID" as 1,2,3,4,5,6,7,8,9,10,11,12. But when i see the column data of table, i found that the data is arranged like this: 1 10 11 12 3 4 5 6 7 8 9 Since, the data is already inserted in the above order, i found that in crystal report the same format is coming...but i want the order in exactly ascending order in report finally, if not possible in database. Can someone help me on this?

          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