Professional Documents
Culture Documents
3 Write any two SQL functions that will display the day of month of given date.
d)
Item Scode
Ball Pen 0.25 22
Eraser Small 22
Ball Pen 0.5 21
iii) Anay has given the following command to obtain the sum of Qty of different Scode -
Select SUM() from store having group by Scode;
but he is not getting the desired result. Help her by writing the correct command.
a. Select sum(Scode) from store group by Scode;
b. Select Scode, sum(Scode) from store group by Scode;
c. Select Scode, sum(Qty) from store group by Scode ;
d. Select Scode,sum(Qty) group by Scode having store ;
iv) Ritisha wants to display item details whose item code ending with 6. Choose correct
command-
a) Select * from store where itemno like „%6‟;
b) Select * from store where mod(itemno,10)=6;
c) Select * from store where itemno%10=6;
d) Select * from store where itemno//10=6
Choose the correct option:
i. Both (a) and (c)
ii. Both (c) and (d)
iii. Both (b) and (c)
iv. Only (d)
v) Help Shama to write command to display total number of Pens available in store.
a) Select item from store where item like „Pen%‟;
b) Select count(*) from store where item like „%Pen‟;
c) Select sum(Qty) from store where item like „%Pen%‟;
d) Select * from store where item like „%Pen%‟;
. Help Sejal in understanding the difference between the following with example :
(i) Update and Alter command
OR
How is Primary key and Candidate key related? Explain.
. Consider the String st=’ Happy Foggy Morning ‘. Write commands in SQL to:
i) To remove leading and trailing spaces
ii) To find the length of the string st.
5 Shikha writes the following commands with respect to a table book having fields-
Bookid, Bname, Publisher, Price
Command1 : Select Publisher from book;
Command2: Select Distinct Publisher from book;
She gets the output as 6 publisher name for the first command but gets an output as 4
publisher name for the second command.
Explain the output with justification.
6. Consider the integer number x=6 and y = 2. Write commands in SQL to:
OR
Consider a table Bank with the following data:
Acc_No CName Bname Amount DateofOpen Tot_Trans
1 Karan Kumar Bank of Baroda 15025 12-Dec-1999 10
2 Avi State Bank 25000 17-Jan-2001 3
3 Tanmay Oriental Bank 8000 19-Feb-2003 15
4 Rohini State Bank 38025 02-Jan-1999 9
5 Tanya Saha UCO Bank 17000 20-Aug-2005 10
6 Aditi Arya Oriental Bank 75000 19-Feb-2005 24
Write SQL queries using SQL functions to perform the following operations:
a) To display name of customers whose amount is ending with 25.
b) To display name and date of open whose account is opened in January 1999.
c) To display name and bank name whose account is opened on 19.
th
d) To display customers name who opened account on 50 day of year.
e) To display details of customers whose total transaction is same as number of
characters in their name.