151k views
3 votes
Write an SQL SELECT query that returns the first and last name of each instructor, their salary, and assigns each of them a number.

a) SELECT FirstName, LastName, Salary, ROW_NUMBER() OVER (ORDER BY LastName) FROM Instructors;
b) SELECT FirstName, LastName, Salary, ROWNUM FROM Instructors;
c) SELECT FirstName, LastName, Salary, NUMBER FROM Instructors;
d) SELECT FirstName, LastName, Salary, IDENTITY(1,1) FROM Instructors;

User Skeen
by
8.0k points

1 Answer

6 votes

Final answer:

The correct SQL SELECT query to return the first and last name of each instructor, their salary, and assign each of them a number is using the ROW_NUMBER() function.

Step-by-step explanation:

The correct SQL SELECT query to return the first and last name of each instructor, their salary, and assign each of them a number is:

SELECT FirstName, LastName, Salary, ROW_NUMBER() OVER (ORDER BY LastName) FROM Instructors;

This query uses the ROW_NUMBER() OVER (ORDER BY LastName) function to assign a unique number to each record based on the order of their last names. The result will include the first name, last name, salary, and the assigned number for each instructor.

User DeltaG
by
8.4k points