Question Bank-Chapter 6
Question Bank-Chapter 6
Section A
4) Veena wants to calculate her age, what will be the suitable function she use
from the give list
a) YEAR() b) EXTRACT_YEAR() c) DAYOFYEAR() d) DATE_YEAR()
Answer Key:
1. (a)c) both a and b (b)a) Removes leading and trailing spaces (c)c) 20 b)
(4)a) YEAR() 5)B)TRUNCATE() 6)D)POW() 7)B)0 8)B)True
9)A)SYSDATE() 10)A)YES
Section C (3 marks)
Write the SQL command that will display the current time and date.
Ans. mysql> SELECT NOW();
(xv)SELECT MID('OnlineEducation',2,4);
Section E
Q.1 Consider a table SALESMAN with the following data.
Write SQL queries using SQL functions to perform the following operations:
a) Disaplay salesman name and bonus after rounding off to zero decimal places.
b) Display the position of occurance of the string “ta” in salesman names.
c) Display the four characters from salesman name starting from second
character.
d) Display the month name for the date of join of salesman.
e) Display the month of the weekday for the date join of salesman.
Ans :
Ans.
1) SELECT MONTHNAME(CURDATE());
2) SELECT TRIM(" Panorama ");
3) SELECT DAYNAME('2000-07-22');
4) SELECT INSTR('Gupta Ashwini', 'Ashwini') AS StartingPosition;
5) SELECT MOD(n1, n2);
1) Display 7 characters extracted from 7th left character onwards from the
string 'INDIA SHINING’.
2) Display the position of occurrence of string 'COME' in the string
'WELCOME WORLD'.
3) Round off the value 23.78 to one decimal place.
4) Display the remainder of 100 divided by 9.
5) Remove all the expected leading and trailing spaces from a column userid
of the table 'USERS'.
Ans:
1) If Str = "INFORMATICS PRACTICES ...." and Str1 = "... FOR CLASS XI"Write
commands to print the output as 'informatics practices for class xi'
2) Write commands to display the system date.
3) Write a command to display the name of current month.
4) Write SQL statement to display : Today, the date is <current date>
5) Write command to print the day of the week of your Birthday in the year
2005.
Ans:
1) SELECT CONCAT(LCASE('INFORMATICS PRACTICES'), ' ', LCASE('FOR CLASS
XI'));
2) SELECT SYSDATE();
3) SELECT MONTHNAME(CURDATE());
4) SELECT CONCAT('Today, the date is ', CURDATE()) AS CURDATE;
5) SELECT DAYOFWEEK('2005-07-21');