Horje
Create Stored Procedure Code Example
Create Stored Procedure
CREATE PROCEDURE [dbo].[GetCoursesByStudentId]
    -- Add the parameters for the stored procedure here
    @StudentId int = null
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    -- Insert statements for procedure here
select c.courseid, c.coursename,c.Location, c.TeacherId
from student s 
left outer join studentcourse sc on sc.studentid = s.studentid 
left outer join course c on c.courseid = sc.courseid
where s.studentid = @StudentId
END
Create Procedure
DELIMITER //
 CREATE PROCEDURE GetTop10Customers()
   BEGIN
	SELECT c.first_name, c.last_name, SUM(p.amount) as total_payments
	FROM customer c
	JOIN payment p
		ON c.customer_id = p.customer_id
	GROUP BY c.customer_id
	ORDER BY total_payments DESC
	limit 10;
   END //
 DELIMITER ;




Sql

Related
dump sql file to database postgres Code Example dump sql file to database postgres Code Example
sql multiple into Code Example sql multiple into Code Example
oracle archivelog usage Code Example oracle archivelog usage Code Example
Rows, INSERT INTO, Returning with alias Code Example Rows, INSERT INTO, Returning with alias Code Example
add mysql database to power bi web Code Example add mysql database to power bi web Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7