Aggregating your data can be helpful. Find out how to do this with GROUP BY and GROUP_CONCAT.
- [Instructor] When we need…to divide results in various ways,…we can use the group by keyword…to change the way that a query works.…Let's say we wanted to count up…how many of each first name we have in our database.…Alright.…Select, first name, and count.…First name from people.…That should work, right?…Well it doesn't.…Because when we asked the database…to give us a count of the items in the first name field,…we get one result: 1,000.…
Then that informs the size of the response.…So we just get the first name value…from the last record in the table.…But if we add a clause to the end,…using the group by keyword,…we can tell the database to run our select clause…against each individual grouping…by the field that we specify.…Allot that on the end here.…Group by first name.…That looks a lot more like what we're interested in.…
We can switch this out too for another field.…Alright count, last name, and group by last name.…But this is information that doesn't make any sense.…Because while we're grouping by last name…and counting the occurrences of each,…
- Name the predicate of the following statement: SELECT EyeColor, Age FROM Student WHERE FirstName = 'Tim' ORDER BY LastName ASC;
- Explain what to use to enforce the order in which an expression must be evaluated if the WHERE clause contains multiple expressions to evaluate.
- Identify the best option to join two tables in a database to be able to display data from both.
- List a data type that is not numeric.
- Determine the result of running the following statement on a table containing columns col_1 and col_2:
- INSERT INTO Box (col_1, col_2) VALUES ('A', 'B'), ('A', 'B'), ('A', 'B'), ('A', 'B');
- Determine the best approach of deleting Jon Ramirez (ID 3452) from a Student table.