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, 5124👍, 0💬
Popular Posts:
How can I use tables to structure forms Small forms are sometimes placed within a TD element within ...
Managed Code and Unmanaged Code related ASP.NET - How do you hide Public .NET Classes and other publ...
How To Set Background to Transparent or Non-transparent? - CSS Tutorials - HTML Formatting Model: Bl...
How can a servlet refresh automatically if some new data has entered the database? You can use a cli...
What is continuous and staged representation? CMMI contains 25 key process areas which organization ...