/* Adding a row number to the output */ /* All databases support -----------------------------------------------------*/ select ROW_NUMBER() OVER(order by lname) AS "row num", fname, lname, course_id from student join class on ssn=stu_ssn; /* MySql - also --------------------------------------------------------------*/ set @count:=0; select (@count:=@count+1) as "row num", fname, lname, course_id from student join class on ssn=stu_ssn; /* Oracle also ---------------------------------------------------------------*/ /* Oracle has a keyword called rownum */ select ROWNUM as "row num", fname, lname, course_id from student join class on ssn=stu_ssn;