Connect with us

SQL Function

SQL Group By

mm

Published

on

The GROUP BY is used in conjunction with the aggregate functions to group the result-set by columns.
Syntax:-
SELECT column_name, aggregate_function(column_name) FROM table_name WHERE column_name operator value GROUP BY column_name;
Example:-
If, we want to locate the number of visit. The subsequent SQL counts as Visit grouped by Visitors:-

SELECT Visitors.VisitorName, COUNT(visits.visitID) AS NumberOfvisits FROM visits LEFT JOIN Visitors ON visits.visitorID=Visitors.visitorID GROUP BY VisitorName;

Also Read :   SQL Last()

Hi, Thank you for reading my article. I am Victor, a professional blogger from Jaipur, India.I started webetutorial for blogging & sharing solution for developer questions, and now it’s empowering globally by helping them to make money.I am writing about starting & managing a blogs, WordPress, Magento, Social Media, SEO, Marketing, making money online, Investment, Finance, Gadgets, Fitness and more.

Continue Reading
Advertisement
Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

eighteen − fifteen =

SQL Function

SQL Avg()

mm

Published

on

The AVG() returns the average value of a numeric column.
Syntax:-
SELECT AVG(column_name) FROM table_name;
Example:-
The subsequent SQL gets the average value of the “Price” column from the “Hosting” table:-

SELECT AVG(Price) AS PriceAverage FROM Hosting;

OR

SELECT HostingName, Price FROM Hostings WHERE Price>(SELECT AVG(Price) FROM Hostings);

Also Read :   SQL Last()
Continue Reading

Subscribe to our newsletter

Enter your email address to subscribe to blog and receive notifications of new articles by email.
100% Privacy. No spam guaranteed

Trending