GROUP BY statement is use with SQL Aggregate function like COUNT, MIN, MAX, AVG, SUM for get result in one or more column or row
GROUP BY Syntax
SELECT ColName
FROM TableName
WHERE Condition
GROUP BY ColName
ORDER BY ColName
Example
1. SELECT COUNT(CountryName) FROM City GROUP BY CountryName
2. SELECT COUNT(CountryName) FROM City GROUP BY CountryName ORDER BY COUNT(CountryName)
GROUP BY Syntax
SELECT ColName
FROM TableName
WHERE Condition
GROUP BY ColName
ORDER BY ColName
Example
1. SELECT COUNT(CountryName) FROM City GROUP BY CountryName
2. SELECT COUNT(CountryName) FROM City GROUP BY CountryName ORDER BY COUNT(CountryName)
No comments:
Post a Comment