Results 1 to 4 of 4
  1. #1
    camdiggy is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2013
    Posts
    1

    Division by zero in when I order by column number

    So, I have some complicated calculations I am aliasing in my SQL query. My end goal would be to sort by my final calculation from all the other calculations I have performed but I am running in to some issues. I know I can't sort by referencing the alias itself without saying order by (column number). My calculations are usually pretty small (around .001 and up). Whenever I order by the column number I would like to use, (select...from...where...order by 73) I get a "Division by zero" error in access. I figured this was an issue with how small the calculations were, so I multiplied by 1000000, then ordered by that column number. Still division by zero...I went ahead and changed all 0 values to 1, still division by zero. There are no zero values in the column itself, it's either 1 or something in the thousands. I can order by other columns, just not the one I want to use. I don't want to have to re-do my entire calculations in my order by clause, so I was wondering if anyone had seen something like this or had any idea what I am doing wrong. Thanks!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Totally unfamiliar with this. I have never referenced a column number in queries. If you want to provide db for analysis, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    I haven't seen order by column number either - can you post the SQL of the query?

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I vaguely remember hearing/using this form of ORDER BY, but I couldn't find anything about it in Help.
    I did find a couple of blogs about it:

    http://connectsql.blogspot.com/2010/...n-name-or.html
    http://blog.sqlauthority.com/2010/12...-columnnumber/

    It is useful if you are trying to sort using a calculated field. But, as per the blogs, it is dangerous...

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Combo Box Column Order and Selection
    By Narvic in forum Forms
    Replies: 23
    Last Post: 04-02-2013, 11:56 AM
  2. division by 0
    By kwooten in forum Queries
    Replies: 5
    Last Post: 03-19-2012, 04:37 PM
  3. Division by zero error on a query
    By thorwood in forum Access
    Replies: 3
    Last Post: 05-19-2011, 07:20 AM
  4. How to reset layout column order?
    By GLykos in forum Queries
    Replies: 0
    Last Post: 07-27-2010, 11:26 AM
  5. Column Order, Hidden, Name
    By Eightball3 in forum Forms
    Replies: 1
    Last Post: 06-30-2010, 12:35 PM

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
  •  
Other Forums: Microsoft Office Forums