Advertisements
Advertisements
प्रश्न
Using the table INVENTORY from CARSHOWROOM database, write SQL queries for the following:
- Convert the CarMake to uppercase if its value starts with the letter ‘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.
कोड लेखन
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
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
