Question:

The first value in the output of a SQL query (given below) when run on a table having name “Table-1” is?

SQL Query: SELECT LastName FROM Table-1 WHERE State = "IN" ORDER BY FirstName

LastNameFirstNameStreetNumberStreetNameCityState
SquiresEdwin4589Shamar Rd.UplandIN
RothrockPaul91657Carex Ave.UplandIN
RamirezDouglas123Fake St.SpringfieldIN
PetersonChris4687Windthrow WayKanePA
GibsonDavid354Bluestem St.CarbondaleIL

Show Hint

In SQL, when using tt{ORDER BY}, the sorting happens by the specified column. If you’re selecting a different column (like tt{LastName}) but ordering by tt{FirstName}, ensure you still associate the sorted row correctly to return the right column value.
Updated On: Apr 17, 2025
  • Ramirez
  • Douglas
  • Paul
  • Squires
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is A

Solution and Explanation

We are given the query:

SELECT LastName FROM Table-1 WHERE State = "IN" ORDER BY FirstName

Let's filter the table rows where State is "IN":
- Squires, Edwin — IN
- Rothrock, Paul — IN
- Ramirez, Douglas — IN

Now, order these by the FirstName column:
1. Douglas (Ramirez)
2. Edwin (Squires)
3. Paul (Rothrock)

So, the first entry by alphabetical order of FirstName is Douglas, and the corresponding LastName is Ramirez.
Answer: Ramirez

Was this answer helpful?
0
0

Top Questions on Database Management Systems

View More Questions

Questions Asked in GATE GE exam

View More Questions