हिंदी

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’.

Advertisements
Advertisements

प्रश्न

Using the table INVENTORY from CARSHOWROOM database, write SQL queries for the following:

  1. Convert the CarMake to uppercase if its value starts with the letter ‘B’.
  2. 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.
कोड लेखन
Advertisements

उत्तर

a) Convert the CarMake to uppercase if its value starts with the letter 'B'.

SELECT
    CASE
        WHEN CarMake LIKE 'B%' THEN UPPER(CarMake)
        ELSE CarMake
    END AS CarMake
FROM INVENTORY;

b) If the length of the car's Model is greater than 4, fetch the substring starting from position 3 till the end from the Model attribute.

SELECT
    CASE
        WHEN LENGTH(Model) > 4 THEN SUBSTRING(Model, 3)
        ELSE Model
    END AS Model
FROM INVENTORY;
shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 1: Querying and SQL Functions - Intext Questions [पृष्ठ ९]

APPEARS IN

एनसीईआरटी Informatics Practices [English] Class 12
अध्याय 1 Querying and SQL Functions
Intext Questions | Q 2. | पृष्ठ ९
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×