What is the difference between GROUP BY and ORDER BY in
Sql?
Answers were Sorted based on User's Feedback
Answer / jagadeesh
Groupby: It is a way to sub-total your results,or perform
some other 'aggregate' functions on them.
Orderby: It is a simply a way to sort your results. It
doesn't affect what shows up in your result set,only what
order it is displayed.
Is This Answer Correct ? | 228 Yes | 35 No |
Answer / ashok
order by use for sorting the result,like ascendin or dcending.
Is This Answer Correct ? | 148 Yes | 24 No |
Answer / lalitha
In Group By clause the results are displayed in group wise
manner means it group all the records in a relation together
and then displayed them for a selected set of fields from
the relation and in Order By clause the results are
displayed in some specified order
Is This Answer Correct ? | 55 Yes | 10 No |
Answer / haritharavi
Order by clause is used to sort the rows in ascending or
descending order.Group by clause is used to sort/group a
number of rows together so as to apply aggregate functions.
So order by is only to sort the records where as group by
is to sort and find aggregate functions of each group.
Is This Answer Correct ? | 32 Yes | 5 No |
Answer / niraj kumar
To sort a result, use an ORDER BY clause.
The most general way to satisfy a GROUP BY clause is to
scan the whole table and create a new temporary table where
all rows from each group are consecutive, and then use this
temporary table to discover groups and apply aggregate
functions (if any).
ORDER BY [col1],[col2],...[coln]; Tells DBMS according to
what columns it should sort the result. If two rows will
hawe the same value in col1 it will try to sort them
according to col2 and so on.
GROUP BY [col1],[col2],...[coln]; Tells DBMS to group
(aggregate) results with same value of column col1. You can
use COUNT(col1), SUM(col1), AVG(col1) with it, if you want
to count all items in group, sum all values or view
average.
Is This Answer Correct ? | 24 Yes | 7 No |
Answer / zaid manzoor
The ORDER BY keyword is used to sort the result-set.
The ORDER BY Keyword
The ORDER BY keyword is used to sort the result-set by a specified column.
The ORDER BY keyword sort the records in ascending order by default.
If you want to sort the records in a descending order, you can use the DESC keyword.
SQL ORDER BY Syntax
Aggregate functions often need an added GROUP BY statement.
The GROUP BY Statement
The GROUP BY statement is used in conjunction with the aggregate functions to group the result-set by one or more columns.
Is This Answer Correct ? | 19 Yes | 5 No |
Answer / priya
groupby:example:regcode:2 transdate;6/4/2012
trans date 5/5/2012
order by example reg code 2 everybussiness deatail by down
to up
Is This Answer Correct ? | 7 Yes | 2 No |
Answer / hareesha k
GROUP BY is used to group values from a column, and, if
necessary, perform calculations on that column. We can use
aggregation functions (e.g. COUNT, SUM, AVG) on the grouped
column.
The result of the GROUP BY is ordered by the column that
grouped.
The ORDER BY clause is used only for ordering(Sorting) the
query results.Asc by default.
Is This Answer Correct ? | 3 Yes | 1 No |
Answer / jamsheed
Order by keyword is used to sort the result set in asc & desc order.
Group by keyword is used to group the resultset. It is used to find distinct values also.
Is This Answer Correct ? | 2 Yes | 1 No |
Answer / ram
Group by controls the presentation of the rows,Where as
order by controls the presentation of the columns for the
results of the SELECT statement.
Is This Answer Correct ? | 58 Yes | 68 No |
What you can use regular expression for in mysql?
What is the difference between having and where clause in mysql? Explain
Why we use mysql workbench?
How do I save in mysql?
Can I use mysql for free?
What is the purpose of mysql database?
How can you do the fine tunning?
How do I view mysql logs?
How to get help information from the server?
How you will show all data from a table.
Explain MySQL architecture?
What is database migration in mysql?