Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2015
    Posts
    3

    Answered: ORDER BY - After Hyphen/decimal - HELP NEEDED!!

    select sum(woitem.qtytarget) as total, wo.num, sysuser.username
    from woitem
    join wo
    ON wo.id = woitem.woid
    Join moitem
    on moitem.id = woitem.moitemid
    Join mo
    ON mo.id = moitem.moid
    LEFT JOIN SYSUSER ON mo.userid = sysuser.id
    group by sysuser.username, num
    order by wo.num Asc

    wo.num starts with 1000:001, 1001:001, 1002:001......999:001, 998:001, 99:001

    But I need an order with displays 1:001, 2:001, 3:001,.....999:001, 1000:001, 1001:001, 1002:001
    Last edited by prettyricky; 08-28-15 at 13:23. Reason: Spelling mistake in title - HELP NEEDED in order by

  2. Best Answer
    Posted by Thrasymachus

    "So it is a car or a varchar field and you want to sort it like a integer? If so use SUBSTRING to split out the values to the left and right of the colon and then cast those values as integers, and then sort by those 2 values.This solution is not guaranteed to be very efficient."


  3. #2
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    So it is a car or a varchar field and you want to sort it like a integer? If so use SUBSTRING to split out the values to the left and right of the colon and then cast those values as integers, and then sort by those 2 values.This solution is not guaranteed to be very efficient.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •