SQL Question - Answer For Xii For Practical
SQL Question - Answer For Xii For Practical
Write SQL commands for the queries (i) to (iv) and output for (v) & (viii) based on a table
COMPANY and CUSTOMER.
1. To display those company name which are having prize less than 30000.
2. To display the name of the companies in reverse alphabetical order.
3. To increase the prize by 1000 for those customer whose name starts with „S?
4. To add one more column total price with decimal] 10,2) to the table customer
5. SELECT COUNT (*), CITY FROM COMPANY GROUP BY CITY;
6. SELECT MIN(PRICE), MAX(PRICE) FROM CUSTOMER WHERE QTY>10;
7. SELECT AVG(QTY) FROM CUSTOMER WHERE NAME LIKE “%r%;
8. SELECT PRODUCTNAME,CITY, PRICE
FROM COMPANY, CUSTOMER WHERE
COMPANY. CID=CUSTOMER.CID AND
PRODUCTNAME=”MOBILE”;
Answer:
5.
6. 50000,70000
7. 11
8.
Question 2:
Consider the following tables SCHOOL and ADMIN and answer this question :
1. To display TEACHERNAME, PERIODS of all teachers whose periods are more than 25.
2. To display all the information from the table SCHOOL in descending order of experience.
3. To display DESIGNATION without duplicate entries from the table ADMIN.
4. To display TEACHERNAME, CODE and corresponding DESIGNATION from tables
SCHOOL and ADMIN of Male teachers.
Answer:
Question 3:
Write SQL commands for the queries (i) to (iv) and output for (v) to (viii) based on the tables
Watches’ and Sale given below.
1. TO DISPLAY ALL THE DETAILS OF THOSE WATCHES WHOSE NAME ENDS WITH
‘TIME’
2. TO DISPLAY WATCH’S NAME AND PRICE OF THOSE WATCHES WHICH HAVE PRICE
RANGE IN BE-TWEEN 5000-15000.
3. TO DISPLAY TOTAL QUANTITY IN STORE OF UNISEX TYPE WATCHES.
4. TO DISPLAY WATCH NAME AND THEIR QUANTITY SOLD IN FIRST QUARTER;
5. SELECT MAX (PRICE), MIN(QTY_STORE) FROM WATCHES;
6. SELECT QUARTER, SUM(QTY SOLD) FROM SALE GROUP BY QUARTER;
7. SELECT WATCH_NAME, PRICE, TYPE FROM WATCHES W, SALE S WHERE W.
WAT£H1D!=S.WATCHID; (viii) SELECT WATCH_NAME, QTYSTORE, SUM (QTY_SOLD),
QTY_STORESUM (QTYSOLD) “STOCK” FROM WATCHES W, SALE S WHERE W.
WATCHID = S.WATCHID GROUP BY S.WATCHID;
Answer:
Question 4:
Answer the questions (a) and (b) on the basis of the following tables SHOP and ACCESSORIES.
1. To display Name and Price of all the Accessories in ascending order of their Price.
2. To display Id and SName of all Shop located in Nehru Place.
3. To display Minimum and Maximum Price of each Name of Accessories.
4. To display Name, Price of all Accessories and their respective SName where they are
available.
(b) Write the output of the following SQL
Answer:
(a)
(b)
Q. Write a program that depending upon user's choice, either
pushes or pops an element in a stack the elements are shifted
towards right so that top always remains at 0th (zero) index.
SOLUTION:
stack = [ ]
while True :
com = input("Enter ( Push or Pop ) : ")
elif len(stack) == 0 :
print("Underflow")
Q. A line of text is read from the input terminal into a stack. Write a program to output the
string in reverse order, each character appearing twice. (e.g., the string a b c d e should be
changed to ee dd cc bb aa)
SOLUTON:
stack.reverse()
for j in stack :
print( j , end=" ")