Results 1 to 13 of 13
  1. #1
    jaryszek is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    568

    Query to sort in reverse order

    Hi,



    I want to and new column to query and sort it in reverse order.

    I have numbers in table:

    Table1.Numbers: 1, 5, 10, 15
    and want to write query to add ReverseNumberCalculated column: 15, 10, 5, 1

    How can i do it?

    Write subquery or something?

    Best,
    Jacek

  2. #2
    jaryszek is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    568
    One more thing. For each number i have server:
    S1, S2, S3, S4.

    For S1 = 1, S2 = 5, S3 = 10, S4 = 15
    So it should be S1 = 15; S2 = 10; S3 = 5; S4 = 1

    Best,
    Jacek

  3. #3
    jaryszek is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    568
    It should be like this:

    Click image for larger version. 

Name:	Screenshot_3.png 
Views:	14 
Size:	38.3 KB 
ID:	33402

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,992
    You don't need to add an extra column
    Create a query and sort by Number DESC

    BUT CHANGE the field name - Number is a RESERVED word. Not sure about SERVER???
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  5. #5
    jaryszek is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    568
    Hi ridders52,

    how are you? than you

    I can create the query and sort it by desc number but i want to have output like in the picture.
    So i want to have in one record for S1= Number = 1 and ReversedNumber = 15...

    Best,
    Jacek

  6. #6
    Gicu's Avatar
    Gicu is offline VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,125
    In your new calculated field use ABS(0-[Number]) (replace the name of the number field as per ridders52 suggestion).

    Cheers,
    Vlad

  7. #7
    jaryszek is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    568
    Hi Vlad,

    i do not understand unfortunately.
    Can you give some example?

    ABS is creating absolute number, so from -3 result will be 3.
    How this is connected to this case?

    Best,
    Jacek

  8. #8
    Gicu's Avatar
    Gicu is offline VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,125
    Sorry, you're right,I rushed to the conclusion. I think you need to use a couple of ranking queries, please have a look at the attached file.

    Sorry again for the first post!
    Vlad
    Attached Files Attached Files

  9. #9
    jaryszek is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    568
    Hi Vlad,

    great thank you!

    Understand all except working of subquery:

    Code:
    select Count(*) from tblServer 
                  where Number<tblServ.Number 
                      and 
                            Server=tblServer.Server 
               ) +1 AS RankASC
    how can i imagine to see the solution in my head ?

    Best,
    Jacek

  10. #10
    Gicu's Avatar
    Gicu is offline VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,125
    Hi Jacek!

    Not sure if it is a question or a comment. Here are some links that might help:

    https://answers.microsoft.com/en-us/...c-68b599b31bf5
    https://stackoverflow.com/questions/...s-access-query

    Cheers,
    Vlad

  11. #11
    jaryszek is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    568
    It is a question.

    how this count is working here?

    I am counting all where number < number?
    what does it mean?

    Jacek

  12. #12
    Gicu's Avatar
    Gicu is offline VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,125
    Hi Jacek,

    It is doing a ranking based on the number field. So for the first server (S1) with the number of 1 the count of servers with a number less than 1 is 0 (so we add 1 to give you the "rank" of 1). And so on until the last.

    Cheers,
    Vlad

  13. #13
    jaryszek is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    568
    aa great!

    thank you
    Now i am understanding !

    Best,
    Jacek

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

Similar Threads

  1. Reverse the display order of names
    By Khatuaaccess in forum Access
    Replies: 3
    Last Post: 10-17-2016, 07:57 AM
  2. Sort by Month Order
    By sk88 in forum Reports
    Replies: 1
    Last Post: 03-17-2015, 05:22 PM
  3. Access Query Sort Order every other one
    By Gina Maylone in forum Access
    Replies: 2
    Last Post: 09-29-2014, 11:26 AM
  4. Sort Order In Query Dies On Filter
    By VariableZ in forum Queries
    Replies: 12
    Last Post: 07-09-2013, 08:19 PM
  5. Sort order in a sub form
    By roar58 in forum Forms
    Replies: 1
    Last Post: 03-17-2012, 08:57 PM

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