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, 5165👍, 0💬
Popular Posts:
How To Test Transaction Isolation Levels? - MySQL FAQs - Transaction Management: Commit or Rollback ...
What is difference between ADPATCH and OPATCH ? # ADPATCH is utility to apply ORACLE application Pat...
What is the method to customize columns in DataGrid? Use the template column.
Can Sub Procedure/Function Be Called Recursively? - Oracle DBA FAQ - Creating Your Own PL/SQL Proced...
What is the benefit of using #define to declare a constant? Using the #define method of declaring a ...