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. SQL ordering

SQL ordering

Scheduled Pinned Locked Moved Database
databasequestion
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.
  • T Offline
    T Offline
    tom groezer
    wrote on last edited by
    #1

    I have a SQL result coming as ID Created Status ================================================ 1 2008-05-10 Active 4 2008-05-11 Active 3 2008-05-12 Inactive 2 2008-05-13 Inactive I want the same to come as (Order by ID) ID Created Status ================================================ Con1 2008-05-10 Active Con2 2008-05-13 Inactive Con3 2008-05-12 Inactive Con4 2008-05-11 Active How do i do this using SQL

    L M B 3 Replies Last reply
    0
    • T tom groezer

      I have a SQL result coming as ID Created Status ================================================ 1 2008-05-10 Active 4 2008-05-11 Active 3 2008-05-12 Inactive 2 2008-05-13 Inactive I want the same to come as (Order by ID) ID Created Status ================================================ Con1 2008-05-10 Active Con2 2008-05-13 Inactive Con3 2008-05-12 Inactive Con4 2008-05-11 Active How do i do this using SQL

      L Offline
      L Offline
      leckey 0
      wrote on last edited by
      #2

      Are you wanting this for display purposes only or for saving to a DB? If you are inserting you should be able to do something like INSERT INTO tbl_WHATEVER "CON" & ID I think you could do something similar for display purposes: SELECT ("Con" & ID, Created, Status) FROM tbl_WHATEVER SORT ASC I haven't tried it though.

      Shhhhh..... http://craptasticnation.blogspot.com/[^]

      1 Reply Last reply
      0
      • T tom groezer

        I have a SQL result coming as ID Created Status ================================================ 1 2008-05-10 Active 4 2008-05-11 Active 3 2008-05-12 Inactive 2 2008-05-13 Inactive I want the same to come as (Order by ID) ID Created Status ================================================ Con1 2008-05-10 Active Con2 2008-05-13 Inactive Con3 2008-05-12 Inactive Con4 2008-05-11 Active How do i do this using SQL

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

        Try this: Select 'Con' + convert(varchar(20),ID), * From TableName Order by ID (desc)

        Never underestimate the power of human stupidity RAH

        1 Reply Last reply
        0
        • T tom groezer

          I have a SQL result coming as ID Created Status ================================================ 1 2008-05-10 Active 4 2008-05-11 Active 3 2008-05-12 Inactive 2 2008-05-13 Inactive I want the same to come as (Order by ID) ID Created Status ================================================ Con1 2008-05-10 Active Con2 2008-05-13 Inactive Con3 2008-05-12 Inactive Con4 2008-05-11 Active How do i do this using SQL

          B Offline
          B Offline
          Blue_Boy
          wrote on last edited by
          #4

          select 'Con'+cast(ID as varchar),Created,Status from myTable order by ID asc


          I Love T-SQL "Don't torture yourself,let the life to do it for you."

          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