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. Ordering rows by multiple coluimns

Ordering rows by multiple coluimns

Scheduled Pinned Locked Moved Database
algorithmshelp
5 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.
  • B Offline
    B Offline
    Branislav Vidovic
    wrote on last edited by
    #1

    Hy! Here is the situation: I am interested in ordering rows in a returned querie (full outer join querie) and I need to do the ordering for 2 columns. Now, the thing is, simple ORDER BY can't help me. If you use

    ORDER BY column1, column2

    the result is sorting querie by column1 and then column2. This does not satisfy my situation. I wolud like sorting to be in a way that sorting happens for these 2 columns at once. I would like the result to look like this if it is possible:

    column1 column2
    25.5.1984 null
    null 30.5.1985
    null 17.5.1993
    2.2.2005 null

    The columns are type short date/time. Cheers!

    M 1 Reply Last reply
    0
    • B Branislav Vidovic

      Hy! Here is the situation: I am interested in ordering rows in a returned querie (full outer join querie) and I need to do the ordering for 2 columns. Now, the thing is, simple ORDER BY can't help me. If you use

      ORDER BY column1, column2

      the result is sorting querie by column1 and then column2. This does not satisfy my situation. I wolud like sorting to be in a way that sorting happens for these 2 columns at once. I would like the result to look like this if it is possible:

      column1 column2
      25.5.1984 null
      null 30.5.1985
      null 17.5.1993
      2.2.2005 null

      The columns are type short date/time. Cheers!

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

      Try this

      order by isnull(column1,column2)

      Never underestimate the power of human stupidity RAH

      L B 3 Replies Last reply
      0
      • M Mycroft Holmes

        Try this

        order by isnull(column1,column2)

        Never underestimate the power of human stupidity RAH

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        Nice one! :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


        1 Reply Last reply
        0
        • M Mycroft Holmes

          Try this

          order by isnull(column1,column2)

          Never underestimate the power of human stupidity RAH

          B Offline
          B Offline
          Branislav Vidovic
          wrote on last edited by
          #4

          Does not seem to help..

          1 Reply Last reply
          0
          • M Mycroft Holmes

            Try this

            order by isnull(column1,column2)

            Never underestimate the power of human stupidity RAH

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #5

            I just happened to need this today, in MySQL though. There the function exists and is called ifnull. Works great. Thanks. :)

            Luc Pattyn [Forum Guidelines] [My Articles]


            The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


            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