From the course: Advanced MySQL Database Administration
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Solution: Stored procedures - MySQL Tutorial
From the course: Advanced MySQL Database Administration
Solution: Stored procedures
- [Instructor] All right, this is the solution video for your assignment on stored procedures. Stored procedures are an awesome way to either automate your own work or to enable others who are not necessarily SQL power users to still get access to data. So as a reminder, Sally is hoping that she can pull the total orders and a sum of revenue for any given time period. She'd love to just be able to specify a startDate and endDate without having to do much else. So this is where stored procedures will come in and I'll jump into workbench and I can walk you through how we do it. All right, so first, before we do anything with creating a stored procedure, I'm going to simply write the SELECT statement. So we're going to be pulling from the orders table and what she wants to see is a count of order_id values. So that'll give us the number of orders and we can call that total_orders. And then also she wants to know the sum of revenue. So we'll do SUM of price_usd as total_revenue. And from…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.