Skip to content
Activities · Activity 1.2

Q.Using the table INVENTORY from CARSHOWROOM database, write sql queries for the following:

(a) Convert the CarMake to uppercase if its value starts with the letter ‘B’.
(b) If the length of the car’s model is greater than 4 then fetch the substring starting from position 3 till the end from attribute Model.
Tamil Nadu DgeTextbookSubjective· 3mImportance★★★★★est
10% · 4/40 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

Concept understanding — Conditional String Functions

Conditional String Functions – A First Look

Imagine you have a list of customer names, and you want to pull out only those whose names start with "A". Or suppose you have a column of email addresses, and you need to check which ones contain the domain "@gmail.com". In each case, you are not just looking at the whole string — you are applying a condition to decide what to do with it.

That is the core idea: a conditional string function is a tool that performs an operation on text only when a certain condition is met. If the condition is false, it does something else (or nothing). It is the "if-then-else" logic applied to words, letters, and sentences.

The everyday intuition

Think of a teacher sorting answer sheets. The teacher says: "If the student's name starts with 'S', put the sheet in the blue pile; otherwise, put it in the red pile." That is a conditional action on text. The teacher is not just reading names — she is making a decision based on the first letter.

In data work, you often face the same situation. You have a column of text values, and you need to transform, extract, or flag them based on some rule. A conditional string function lets you encode that rule so the computer does it automatically.

What it does precisely

A conditional string function takes three things:

  • A text value (or a reference to a cell containing text)
  • A condition (a test that returns true or false — for example, "does this text contain the word 'urgent'?")
  • An action (what to do if the condition is true) and optionally a fallback (what to do if false)

The function checks the condition. If true, it performs the action on the text. If false, it either performs the fallback or leaves the text unchanged.

Note

In spreadsheet tools like Excel or Google Sheets, the most common conditional string function is IF combined with text functions like LEFT, RIGHT, MID, FIND, or SEARCH. For example: =IF(LEFT(A1,1)="A", "Starts with A", "Does not start with A"). The condition is LEFT(A1,1)="A", the action is to return one message, and the fallback returns another.

Why it matters

In commerce and humanities work, you rarely deal with pure numbers. You deal with names, addresses, product codes, order IDs, feedback comments, and category labels. Conditional string functions let you:

  • Clean data – For example, flag all entries where a city name is misspelled by checking if it matches a standard list.
  • Categorise records – For instance, label a customer as "VIP" if their membership ID contains the letter "V".
  • Extract information – Pull out the area code from a phone number only if the number starts with a certain digit.
  • Validate entries – Check whether an email address contains an "@" symbol and a dot, and return "Valid" or "Invalid" accordingly.

Without conditional string functions, you would have to inspect each text entry manually — impossible for thousands of rows.

A concrete example (no numbers) …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.