Arrange the following query snippets in correct order to find the length of FirstName where it starts with 'A'. The result should be sorted as per the order of length of FirstName.
A. WHERE LEFT(FirstName,1)='A'
B. SELECT FirstName, LENGTH(FirstName)
C. ORDER BY LENGTH(FirstName)
D. FROM Employee
Arrange the following query snippets in correct order to find the length of FirstName where it starts with 'A'. The result should be sorted as per the order of length of FirstName.
A. WHERE LEFT(FirstName,1)='A'
B. SELECT FirstName, LENGTH(FirstName)
C. ORDER BY LENGTH(FirstName)
D. FROM Employee
Solution
A SQL query must follow the clause order SELECT, FROM, WHERE, ORDER BY.
B. SELECT FirstName, LENGTH(FirstName)
D. FROM Employee
A. WHERE LEFT(FirstName,1)='A'
C. ORDER BY LENGTH(FirstName)
Options 1 and 2: WHERE and FROM cannot come before SELECT, because every query starts with SELECT.
Option 3: ORDER BY must come after WHERE, because rows are filtered first and then sorted.
Related questions:
2025: 15 May Shift 2
2025: 20 May Shift 1
2025: 27 May Shift 2
2025: 3 June Shift 2
2025: 21 May Shift 1
2025: 20 May Shift 1