New to SQL and trying to figure out grouping. So far I have a few questions. When I look at an example from w3schools I see this.
SELECT column_name, aggregate_function(column_name) FROM table_name WHERE column_name operator value GROUP BY column_name
So by looking at this example, my GROUP BY column name has to match the SELECT column name. Is that always the case? Can I group by another column within the same table?
Do I have to have a aggregate_function such as sum? What if I am just trying to group by a certain column?
For example what I am trying to do is this - Display employee name and group them by title.
SELECT Last_Name FROM Employee GROUP BY Title
When I try this I get this error - Column 'Employee.Last_Name' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.