PS Query & SQL

 View Only
  • 1.  Sort Help

    Posted 08-07-2025 07:27 AM

    Hello everyone,

    Can I just say, that I love this group.... the hints, tips and tricks are great and I've learnt a lot by just lurking. So thank you all.

    I use PSQuery quite a lot and would class myself as in intermediate user but I'm a little bit puzzled as to how I would go about defining a sort order.

    I would like my query results to come back in a specific order that I can define from one field.  How would I go about this?

    I'm currently using record CLASS_TBL_SE_VW - Class Table Student Enrl View and I want to sort on the CLASS_SECTION - Class Section field in a none alpha manner.

    Thanks in advance.

    Tracey



    ------------------------------
    Tracey Einig Jones
    Business Support Officer
    Liverpool John Moores University
    ------------------------------
    Alliance 2026 Registration is Open!


  • 2.  RE: Sort Help

    Posted 08-07-2025 08:43 AM
    Hi Tracey,

    I agree, this is a great group, and I have learned a great deal from the collective intellect!

    Without knowing the specific, my advice in general is to use an expression to manipulate the field, CLASS_SECTION and return that expression as a separate field and start sorting on that. If you provide more specific info on what you are trying to achieve, we can try to give a better answer.

    Thanks!

    Jeffrie

    On Thu, Aug 7, 2025 at 7:27 AM Tracey Einig Jones via Higher Education User Group <Mail@heug.org> wrote:
    Hello everyone, Can I just say, that I love this group.... the hints, tips and tricks are great and I've learnt a lot by just lurking. So thank...
    Higher Education User Group

    PS Query & SQL

    Post New Discussion
    Sort Help
    Reply to Thread
    Aug 7, 2025 7:27 AM
    Tracey Einig Jones

    Hello everyone,

    Can I just say, that I love this group.... the hints, tips and tricks are great and I've learnt a lot by just lurking. So thank you all.

    I use PSQuery quite a lot and would class myself as in intermediate user but I'm a little bit puzzled as to how I would go about defining a sort order.

    I would like my query results to come back in a specific order that I can define from one field.  How would I go about this?

    I'm currently using record CLASS_TBL_SE_VW - Class Table Student Enrl View and I want to sort on the CLASS_SECTION - Class Section field in a none alpha manner.

    Thanks in advance.

    Tracey



    ------------------------------
    Tracey Einig Jones
    Business Support Officer
    Liverpool John Moores University
    ------------------------------
      Reply to Community   Reply to Sender via Email   View Thread   Recommend  



     
    You are subscribed to "PS Query & SQL" as jedobr@umich.edu. To change your subscriptions, go to My Subscriptions. To remove yourself from this community discussion, you can unsubscribe at any time.
    Alliance 2026 | March 8-11, 2026 | Orlando, FL


    --
    Jeffrie Brooks | BUSINESS SYSTEM ANALYST
    UNIVERSITY OF MICHIGAN | INFORMATION AND TECHNOLOGY SERVICES
    734-647-8763 | jedobr@umich.edu



    Alliance 2026 Registration is Open!


  • 3.  RE: Sort Help

    Posted 08-07-2025 08:43 AM

    Create an expression that assigns a number value to how you want to sort, then add it to the field list, and then sort on that column.

     

    If you want class sections that start with 4 to sort first, and H to sort second, and 2 to sort third,  for example, then

     

    (Case

    When A.CLASS_SECTION Like '4%' Then 1

    When A.CLASS_SECTION Like 'H%' Then 2

    When A.CLASS_SECTION Like '2%' Then 3

    Else 4

    End)

     

     

     

     

    Stephen Forrest

     

    Institutional Research Analyst the Third

    University Decision Support

    Enrollment Management Research Group

    Office of the Provost

    Southern Methodist University

    sforrest@smu.edu

    214-768-4015

     

    "The only reason we put the data in, is to take the data out."

     

     

     

     




    Alliance 2026 Registration is Open!


  • 4.  RE: Sort Help

    Posted 08-07-2025 02:09 PM

    I may be over simplifying this, but have you used the 'Reorder/Sort' radio button on your "fields" tab within query manager? See below:



    ------------------------------
    Juan Mercado
    Systems Analyst
    Cerritos College
    ------------------------------

    Message from the HEUG Marketplace:
    ------------------------------
    Find, Review, and Engage with Higher Education-focused solution providers, products, and services using the HEUG Marketplace.
    ------------------------------

    Alliance 2026 Registration is Open!


  • 5.  RE: Sort Help

    Posted 08-08-2025 08:26 AM
    Not knowing exactly how your CLASS_SECTION is contructed but taking a guess maybe you can create an expression similar to this/use as field and sort

    case 
    when substr(A.CLASS_SECTION,-1) between 'A' and 'Z' then substr(A.CLASS_SECTION,1,3)
    when substr(A.CLASS_SECTION,-2) between 'AA' and 'ZZ' then substr(A.CLASS_SECTION,1,2) else A.CLASS_SECTION end



    When I am using something as a sort only I make the Length 0 and set the Heading Text as No Heading



    Hope this helps,
    Bob
    --
    Bob Fogarty
    LionPATH - Reporting Team Lead
    The Pennsylvania State University



    Alliance 2026 Registration is Open!


  • 6.  RE: Sort Help

    Posted 08-08-2025 08:27 AM

    I'm saving this!  Thanks, Robert, for sharing. 

     




    Alliance 2026 Registration is Open!