What is the difference between GROUP BY and ORDER BY in
Sql?
Answer Posted / 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 |
Post New Answer View All Answers
How can we convert between Unix & MySQL timestamps?
Is oracle mysql free?
What are the advantages of mysql?
Is sqlite faster than mysql?
How can I insert images into a Mysql database?
What is the latest version of mysql?
Does mysql need a server?
Why do gaps in sequences occur?
Is mysql a server or database?
What are triggers in mysql?
How do I create a mysql database?
How to get current MySQL version?
1.how to fetch a value and Execute store procudure in mysql(INNODB) using phpMyAdmin? 2.can i wright a package in mysql database(INNODB)?
Where is the mysql config file?
Which is faster mysql or mongodb?