+ 1
what are GROUP BY Functions??? what is the query to apply this function to the table??
2 Antworten
+ 4
GROUP BY is used to group data when using aggregate functions (such as COUNT, SUM, MAX, etc.). It is used between the WHERE and HAVING clauses.
For example:
SELECT City, COUNT(CustomerID)
FROM CustomerTable
will NOT work unless you define how you want to group the data. In this case you want to group the data by City and show how many customers are in each city so you add "GROUP BY City".
SELECT City, COUNT(CustomerID)
FROM CustomerTable
WHERE ....
GROUP BY City
HAVING ....
ORDER BY City
WHERE can be used to select information on a field (such as City = 'New York').
HAVING is similar to WHERE but is used with the GROUP BY function to select information within the group (such as COUNT(CustomerID) > 10, which would show cities with more than 10 customers).
- 2
Hmmm