Skip to content
Question
Q.

(a) Shalini, who works as a database designer in the hotel industry, has created a table named Guest to keep track of guest details as shown below : Table : Guest

GuestIDGuestNameRoomNumberCheckInDateCharges
G101Harish1012025-04-033000
G102Sunita1012025-04-033000
G103Ramesh1022025-05-045000
G104Bhumika1032025-06-023500

Write a suitable SQL query for the following : I. Display last 3 characters of guest name in upper case. II. Display the name of the guest along with the day name of check-in date. III. Display the remainder when charges are divided by 1000. IV. Extract and display three characters, starting from the second character, of each guest name. OR (b) Consider the following table and write the output of the following SQL Queries. Table : ORDERS

ORDERIDCUSTOMERNAMETOTALAMOUNTDISCOUNTORDERDATE
101Hemant5000102024-03-01
102Neha700015NULL
103Keshav300052024-01-20
104Sandhya4500NULL2023-12-25

Write the output of the following SQL Queries : I. SELECT CUSTOMERNAME FROM ORDERS WHERE DISCOUNT IS NOT NULL; II. SELECT CUSTOMERNAME, DISCOUNT FROM ORDERS WHERE DISCOUNT BETWEEN 5 AND 10; III. SELECT MONTHNAME(ORDERDATE) FROM ORDERS WHERE ORDERDATE IS NOT NULL; IV. SELECT ORDERID, DAY(ORDERDATE) FROM ORDERS;

CBSECBSE Class XII Board 2026Subjective· 4mImportance★★★★★
🔒 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): use UPPER(RIGHT(...)), DAYNAME(...), MOD(...,1000) and MID(...,2,3) on the Guest table.

Part (b): outputs are I {Hemant,Neha,Keshav}; II {Hemant 10, Keshav 5}; III {March,January,December}; IV {101→1,102→NULL,103→20,104→25}.

Part (a)

I. Last 3 characters of guest name in upper case — RIGHT() takes the last 3 letters, UPPER() capitalises them.

SELECT UPPER(RIGHT(GuestName, 3)) FROM Guest;

Harish→ISH, Sunita→ITA, Ramesh→ESH, Bhumika→IKA.

II. Guest name with the day name of the check-in date — DAYNAME() returns the weekday.

SELECT GuestName, DAYNAME(CheckInDate) FROM Guest;

III. Remainder when charges are divided by 1000 — use MOD() (or the % operator).

SELECT MOD(Charges, 1000) FROM Guest;

3000→0, 3000→0, 5000→0, 3500→500.

IV. Three characters starting from the 2nd character — MID(str, start, length) (SQL positions start at 1).

SELECT MID(GuestName, 2, 3) FROM Guest;
``` …

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.