Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Show how to use upper, rtrim and Itrim functions in a select statement to select

ID: 3796436 • Letter: S

Question

Show how to use upper, rtrim and Itrim functions in a select statement to select title and ssn information of all instructors with last name to be "George" to retrieve row 1 and row 3. Notice that although George has different upper case and lower case combinations, we deem different spellings of "George" the same at conceptual level. (In this problem, in order to test out upper, rtrim and ltrim, we have to use char data type for both last name and first name fields! Pay attention to the upper case and lower case, and spaces in the table.)

Explanation / Answer

Our aim is match
GEORge with gEorgE
george with George
george with GEORGE

ltrim removes whitespace from the left side of a string
rtrim removes whitespace from right side of a string

So if there are extra spaces we can use ltrim and rtrim to remove those spaces.
Then we have to convert each name into its upper case and then we match

EX: upper(GEORge) is GEORGE
   upper(gEorgE) is GEORGE

   So these two are equal