Skip to content
Question
Q.

Ms. Mohini is working in a school and stores the details of all students in a table SCHOOLDATA.

TABLE : SCHOOLDATA

AdmnoNameClassHousePercentGenderDob
20150001Aditya Das10Green86Male2006-02-20
20140212Harsh Sharma11Red75Male2004-10-05
20090234Swapnil Pant10Yellow84Female2005-11-21
20130216Soumen Rao9Red91Male2006-04-10
20190227Rahil Arora10Blue70Male2005-05-14
20120200Akasha Singh11Red64Female2004-12-16

Write SQL statements from the above given table to : (i) To remove leading spaces from the column Name. (ii) Display the names of students who were born on Sunday. OR Predict the output of the following SQL queries from the given table : SCHOOLDATA (i) SELECT MAX(Percent) FROM SCHOOLDATA; (ii) SELECT LEFT(Gender,1),Name FROM SCHOOLDATA WHERE YEAR(Dob)=2005;

CBSECBSE Class XII Board 2022Subjective· 2mImportance★★★★★
🔒 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 →

Part (a): (i) UPDATE SCHOOLDATA SET Name = LTRIM(Name); to strip leading spaces; (ii) SELECT Name FROM SCHOOLDATA WHERE DAYNAME(Dob)='Sunday'; for Sunday births.

Part (b): (i) MAX(Percent) = 91; (ii) the second query returns F Swapnil Pant and M Rahil Arora.

Part (a)

(i) Remove leading spaces from the column Name. MySQL's LTRIM() returns a string with all leading (left-hand) spaces removed. To change the stored data permanently we use an UPDATE:

UPDATE SCHOOLDATA SET Name = LTRIM(Name);

(If you only need to display cleaned names without altering the table, SELECT LTRIM(Name) FROM SCHOOLDATA; works too.)

(ii) Display names of students born on Sunday. DAYNAME(date) returns the weekday name ('Sunday', 'Monday', ...). Filter on it:

SELECT Name FROM SCHOOLDATA WHERE DAYNAME(Dob) = 'Sunday'; …

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.