Get the Count of Contact's person by their title. (Table: Customers) below:
Now, below SQL code will get group counts, but I want to add also the names associated with each group if possible please:
SELECT ContactTitle, Count(ContactTitle) FROM Customers
GROUP BY ContactTitle;
Database: This is from NorthWind database.
CodePudding user response:
You can use
SELECT ContactTitle, ContactName, Count(ContactTitle) over (partition by ContactTitle) as usersCoun FROM Customers;