Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8454417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:01:30+00:00 2026-06-10T12:01:30+00:00

The GROUP BY clause groups the rows, but it does not necessarily sort the

  • 0

The GROUP BY clause groups the rows, but it does not necessarily sort the results in any particular order. To change the order, use the ORDER BY clause, which follows the GROUP BY clause. The columns used in the ORDER BY clause must appear in the SELECT list, which is unlike the normal use of ORDER BY. [Oracle by Example, fourth Edition, page 274]

Why is that? Why does using GROUP BY influence the required columns in the SELECT clause?

Also, in the case where I do not use GROUP BY: Why would I want to ORDER BY some columns but then select only a subset of the columns?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T12:01:32+00:00Added an answer on June 10, 2026 at 12:01 pm

    Actually the statement is not entirely true as Dave Costa’s example shows.

    The Oracle documentation says that an expression can be used but the expression must be based on the columns in the selection list.

    expr – expr orders rows based on their value for expr. The expression is based on
    columns in the select list or columns in the tables, views, or materialized views in the
    FROM clause. Source: Oracle® Database
    SQL Language Reference
    11g Release 2 (11.2)
    E26088-01
    September 2011. Page 19-33

    From the the same work page 19-13 and 19-33 (Page 1355 and 1365 in the PDF)

    enter image description here

    enter image description here

    http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_10002.htm#SQLRF01702

    http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_10002.htm#i2171079

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Clearly, when GROUP BY clause used, columns that are not aggregate function should be
I don't think that I can use ORDER BY clause inside the GROUP_CONCAT function.
Can someone please tell me how to use the group by clause, grouping by
My group is trying to build a server using Apache Thrift but we are
I see that in an SQL query, the GROUP BY clause has to precede
Not sure if this is possible, but if it is it would make my
How can I make an ORDER BY clause with a small LIMIT (ie 20
This is sort of SQL newbie question, I think, but here goes. I have
I want to take the results of a where clause on a list and
In my SQL query I am selecting data with GROUP BY and ORDER BY

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.