Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
Can Multiple Columns Be Used in GROUP BY
Can Multiple Columns Be Used in GROUP BY? - MySQL FAQs - SQL SELECT Query Statements with GROUP BY
✍: FYIcenter.com
If you want to break your output into smaller groups, if you specify multiple column names or expressions in the GROUP BY clause. Output in each group must satisfy a specific combination of the expressions listed in the GROUP BY clause. The more columns or expressions entered in the GROUP BY clause, the smaller the groups will be.
The tutorial exercise below shows you how to break data into groups per "tag" and per year when they were created. Then the group function COUNT(*) is applied on each group:
mysql> SELECT tag, YEAR(created), COUNT(*) FROM fyi_links GROUP BY tag, YEAR(created); +------+---------------+----------+ | tag | YEAR(created) | COUNT(*) | +------+---------------+----------+ | DBA | 2005 | 1 | | DBA | 2006 | 2 | | DEV | 2004 | 1 | | DEV | 2006 | 1 | | SQA | 2003 | 1 | | SQA | 2006 | 1 | +------+---------------+----------+ 6 rows in set (0.00 sec)
2007-05-11, 5015👍, 0💬
Popular Posts:
How To Merge Cells in a Column? - XHTML 1.0 Tutorials - Understanding Tables and Table Cells If you ...
How do you open an SSH connection to a remote box? ????
How To Compile a JUnit Test Class? Compiling a JUnit test class is like compiling any other Java cla...
How Oracle Handles Dead Locks? - Oracle DBA FAQ - Understanding SQL Transaction Management Oracle se...
Can two catch blocks be executed? No, once the proper catch section is executed the control goes fin...