0% found this document useful (0 votes)
657 views9 pages

sp-1 FINAL

The document contains a series of multiple choice questions about SQL concepts and commands. It covers topics like SQL functions, clauses, queries, joins, and more. Some key points addressed include: - The COUNT(*) function is used to count rows in a SQL query. - The DELETE clause removes tuples from a database table. - AS is used to change column names or assign names to derived columns in SQL. - BETWEEN is used to select values within a specified range in SQL queries. - DELETE removes rows from a table.

Uploaded by

SUPSNDI SINGH
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
657 views9 pages

sp-1 FINAL

The document contains a series of multiple choice questions about SQL concepts and commands. It covers topics like SQL functions, clauses, queries, joins, and more. Some key points addressed include: - The COUNT(*) function is used to count rows in a SQL query. - The DELETE clause removes tuples from a database table. - AS is used to change column names or assign names to derived columns in SQL. - BETWEEN is used to select values within a specified range in SQL queries. - DELETE removes rows from a table.

Uploaded by

SUPSNDI SINGH
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

1. Which SQL function is used to count the number of rows in a SQL query?

(1)
a)COUNT()
b)NUMBER()
c)SUM()
d)COUNT(*)
2. Which of the following SQL clauses is used to DELETE tuples from a database table? (1)
a)DELETE
b)REMOVE
c)DROP
d)CLEAR
3.________________ is not a category of SQL command. (1)
a)TCL
b)SCL
c)DML
d)DDL

4. Which of the following statement is true? (1)


a) DELETE does not free the space containing the table and DROP free the space containing the
table
b) Both DELETE and DROP free the space containing the table
c) Both DELETE and DROP does not free the space containing the table
d) DELETE free the space containing the table and DROP does not free the space containing the
table

5. What is the purpose of the SQL AS clause? (1)


a) The AS SQL clause is used change the name of a column in the result set or to assign a name
to a derived column
b) The AS clause is used with the JOIN clause only
c) The AS clause defines a search condition
d) All of the mentioned

6. With SQL, how do you select all the records from a table named “Persons” where the value of
the column “FirstName” ends with an “a” ? (1)
a) SELECT * FROM Persons WHERE FirstName=’a’
b) SELECT * FROM Persons WHERE FirstName LIKE ‘a%’
c) SELECT * FROM Persons WHERE FirstName LIKE ‘%a’
d) SELECT * FROM Persons WHERE FirstName=’%a%’

7. With SQL, how can you return the number of not null records in the “Persons” table? (1)
a) SELECT COUNT() FROM Persons
b) SELECT COLUMNS() FROM Persons
c) SELECT COLUMNS(*) FROM Persons
d) SELECT COUNT(*) FROM Persons

8. What does the ALTER TABLE clause do ? (1)


a) The SQL ALTER TABLE clause modifies a table definition by altering, adding, or deleting
table columns and/or constraints
b) The SQL ALTER TABLE clause is used to insert data into database table
c) THE SQL ALTER TABLE deletes data from database table
d) The SQL ALTER TABLE clause is used to delete a database table

9. How can you change “Hansen” into “Nilsen” in the “LastName” column in the Persons table?
(1)
a) UPDATE Persons SET LastName=’Hansen’ INTO LastName=’Nilsen’
b) MODIFY Persons SET LastName=’Nilsen’ WHERE LastName=’Hansen’
c) MODIFY Persons SET LastName=’Hansen’ INTO LastName=’Nilsen’
d) UPDATE Persons SET LastName=’Nilsen’ WHERE LastName=’Hansen’

10. What is the meaning of LIKE ‘%0%0%’ ? (1)


a) Feature begins with two 0’s
b) Feature ends with two 0’s
c) Feature has more than two 0’s
d) Feature has two 0’s in it, at any position

11. Find all the cities with temperature, condition and humidity whose humidity is in the range
of 63 to 79. (1)
a) SELECT * FROM weather WHERE humidity IN (63 to 79)
b) SELECT * FROM weather WHERE humidity NOT IN (63 AND 79)
c) SELECT * FROM weather WHERE humidity BETWEEN 63 AND 79
d) SELECT * FROM weather WHERE humidity NOT BETWEEN 63 AND 79
12. The command to remove rows from a table ‘CUSTOMER’ is (1)
a) DROP FROM CUSTOMER
b) UPDATE FROM CUSTOMER
c) REMOVE FROM CUSTOMER
d) DELETE FROM CUSTOMER WHERE

13. Find the name of those cities with temperature and condition whose condition is either
sunny or cloudy but temperature must be greater than 70. (1)
a) SELECT city, temperature, condition FROM weather WHERE condition = ‘sunny’ AND
condition = ‘cloudy’ OR temperature > 70
b) SELECT city, temperature, condition FROM weather WHERE condition = ‘sunny’ OR
condition = ‘cloudy’ OR temperature > 70
c) SELECT city, temperature, condition FROM weather WHERE condition = ‘sunny’ OR
condition = ‘cloudy’ AND temperature > 70
d) SELECT city, temperature, condition FROM weather WHERE condition = ‘sunny’ AND
condition = ‘cloudy’ AND temperature > 70

14. Find all the tuples having temperature greater than ‘Paris’.(Hint: The following are nested
queries). (1)
a) SELECT * FROM weather WHERE temperature > (SELECT temperature FROM weather
WHERE city = ‘Paris’
b) SELECT * FROM weather WHERE temperature > (SELECT * FROM weather WHERE city
= ‘Paris’)
c) SELECT * FROM weather WHERE temperature > (SELECT city FROM weather WHERE
city = ‘Paris’)
d) SELECT * FROM weather WHERE temperature > ‘Paris’ temperature

15. What is the default URL Django projects? (1)

16.What is the Django shortcut method to more easily render an html response? (1)

17. Logi tier provided by Django framework is the ____________ (1)

18.Fetchall() returns all the records in ______________ form. (1)

19. The following query belongs to which category of mysql query. (1)

x=96

select * from student1 where marks > x;


20. Write a Django command to start a new app named ‘users’ in an existing project? (1)

21. Consider the tables ITEMS & COMPANY. Write SQL commands for query for (i) and
output for (ii) (2)

Table: ITEMS
ID PNAME PRICE MDATE QTY
T001 Soap 12.00 11/03/2007 200
T002 Paste 39.50 23/12/2006 55
T003 Deodorant 125.00 12/06/2007 46
T004 Hair Oil 28.75 25/09/2007 325
T005 Cold Cream 66.00 09/10/2007 144
T006 Tooth Brush 25.00 17/02/2006 455

Table : COMPANY

ID COMPANYNAME City
T001 HLL Mumbai
T008 Colgate Delhi
T003 HLL Mumbai
T004 Paras Haryana

T009 Ponds Noida


T006 Wipro Ahmedabad

i). To display product name, company name & price for those items which IDs
are equal to the IDs of company.
ii . SELECT COUNT(*) FROM ITEMS WHERE ITEMS.ID=COMPANY.ID;

22. Write MySql commands for (i) to (vi) based on the following table. (3)

Table: SUPPLIERS
SCODE SNAME CITY STATE AMOUNT
1001 RAJESH BHIKHIWIND PUNJAB 5000
1002 RAJAT AMRITSAR PUNJAB 5400
1003 PUNEET SONIPAT HARYANA 6200
1004 RACHNA FARIDABAD HARYANA 8400
1005 RAMAN JAMUNANAGAR HARYANA 8940
1006 PRAGTI BISHRAMPUR CHATTISGARH 4800
1007 PRAHAL BABRALA UTTER 3000
AD PARDESH
1008 KOCHER LAKHERI RAJASTHAN 2500

i) Show sname of suppliers whose name is starting with letter ‘P’


ii) Show sname, city of suppliers who belongs to ‘PUNJAB’
iii) Show sname of suppliers in descending order.
iv) Show sname, city of suppliers who belongs to either ‘HARYANA’ or ‘PUNJAB’
v) Change the amount to 5000 where scode is 1008.
vi) Delete the suppliers from SUPPLIERS table who belongs to state ‘UTTER PARDESH’.

23. On the basis of following table answer the given questions: (3)

Table: CUSTOMER_DETAILS

| Cust_ID Cust_Name Acct_Type Accumlt_Amt DOJ Gender

CNR_001 Manoj Saving 101250 1992-02-19 M

CNR_002 Rahul Current 132250 1998-01-11 M

CNR_003 Steve Saving 18200 | 1998-02-21 M

CNR_005 Manpreet Current NULL 1994-02-19 M

(i)Write the degree and cardinality of the above table.

(ii)What will be the output of the following query :Select max(DOJ) From Customer_Details;

(iii)Write the sql query to delete the row from the table where customer has no accumulated
amount.

24. Write commands in SQL for (i) to (iv) and output for (v) and (vi). (3)

Table : Store

Storied Name Location City Noofemp Dateopen salesamt

S101 Planet Bandra Mumbai 7 2015-10-16 40000

S102 Vogue Karol Bagh Delhi 8 2015-07-14 120000

S103 Trends Powai Mumbai 10 2015-06-24 30000

S104 Superfashion Thane Mumbai 11 2015-02-06 45000

S105 Annabelle South Extn. Delhi 8 2015-04-09 60000


S106 trends Defence Delhi 5 2015-03-01 20000
Colony

(i)To display names of stores along with SalesAmount of those stores that have ‘fashion’
anywhere in their store names.

(ii)To display Stores names, Location and DateOfOpen of stores that were opened before 1st
March, 2015.

(iii)To display name and location of those store which have either ‘u’ as second character in their
name.

(iv)To display the City and the number of stores located in that City, only if number of stores is
more than 2.

(v)Select Min(DateOpen) from Store;

(vi)Select Count(Storeid), Noofemp From Store Group By Noofemp Having


Max(Salesamt)<60000;

25. Differentiate Where and Having Clause. (3)

26. In a school, a database named “school” is created in mysql whose password is “cbse”. Smith
is trying to add a new record of a student having details(3,’michelle’,’agartala’) in a ‘student’
table.Write the code in python to read the contents of ‘number.csv’ file consisting of data from a
mysql table and print the data of the table on the screen in tabular form of the table. (4)

27. Write a python program that deletes the last row from the above created ‘student’ table of
mysql database ‘school’. Write a python program that displays first five rows fetched from
‘student’ table of mysql database ‘school’. (4)

28. Identify primary key, candidate key and alternate key from the following table and explain
those keys in detail. (4)
R.No Name Stipend Stream AvgMark Grade Class
101 Neha 450 Medical 89.2 A 11C
102 Damini 400 Commerce NULL B 12B
103 Gaurav 250 Humanities 64.4 C 11A
104 Anu 300 Commerce 67.5 C 12B
105 Vikas 500 Non-Medical 92 A 12A
106 Rubina 450 Non-Medical 88.5 A 12A

29. Answer the following queries: (4)


TABLE: STUDENT
ROLLNO NAME GENDER PHYSICS CHEMISTRY BIOLOGY
1001 ANITHA F 77 55 34
1002 ANIRUDH M 66 55 44
1003 CHIRAG M 88 77 55
1004 DEV M 55 66 56
1005 GANGA F 66 77 88
1006 HARINI F 55 77 88
1007 KRISHNA M 77 88 88
1008 SAHIL M 99 78 99

a. To display the rollno, name, gender form the table


b. To display all the students who are ‘female’.
c. To display the records arranged in ascending order based on gender.
d. To display the details of the students whose name starts with ‘a%’.
e. To display the students who have got Physics marks > 70 and chemistry mark > 70.
f. To display the students who have got Physics marks > 70 or biology mark > 70.
g. To display the details of the student whose name start with ‘a’ and 3rd letter is ‘i’ and
arrange the name in descending order.
h. To display the details of the students whose chemistry marks is between 70 and 90.

30. Answer the following queries. (4)


Table : Student Details
No Name Stipend Stream AvgMark Grade Class
1 Neha 450 Medical 89.2 A 11C
2 Damini 400 Commerce 78.5 B 12B
3 Gaurav 250 Humanities 64.4 C 11A
4 Anu 300 Commerce 67.5 C 12B
Non-
5 Vikas 500 Medical 92 A 12A
Non-
6 Rubina 450 Medical 88.5 A 12A

1) Display all the names of all students who are in Medical Stream.
2) To display name and average of all the students having AvgMark < 70.0.
3) To display the list of all the students with stipend > 350.00 in ascending order of Name.
4) To display the student details with Name, Marks for each student in the table. Marks are
calculated as AvgMark * 5;
5) To insert a new record in the table student with the following data.
7,’Radhika’,500.00,’commerce’,90.8,’A’,’12A’.
6) To display the list of all the students whose names ends with a character ‘a’.
7) To display the list in descending order of AvgMark.
8) To delete the rows of C grade.

31. Create the table SHOP with the suitable datatype for the below given information. (4)
Table Name : Shop
No Shopname Sale Area Cust_Percent Rating City
1 S.M.Sons 2500000 West 68.6 C Delhi
2 Dharohar 5000000 South 81.8 A Mumbai
3 Kriti Art 3000000 North 79.8 B Kolkata
4 Ripple 3800000 North 88 B Mumbai
5 Biswast stores 4560000 East 92 A Delhi
6 Crystal 2900000 South 66.7 A Kolkata

a) Display the names of all shops which are in the area south.
b) To display Name and customer Percentage of all the shops having cust_percent > 80.
c) To display the list of all the shops with sale > 300000 in ascending order of shop name.
d) To display a report with shopname, Area and Rating for each shop in the table, for only
those shops where sale is between 350000 and 400000. (Including both 350000 and
400000).
e) To display the distinct city.
f) To update the customer percent by 5% of south area.
g) To display the list in descending order of sale.
h) To delete all the rows where sale in less than 400000.

32. Consider the following table-EMP and write the outputs for the Q.No.(a) to Q.No.(j) and
write queries for (ix) and (x). (5)
EMP ENAME JOB MGRN HIREDATE SALAR COM DEPT
NO O Y M NO
7369 Sunita Clerk 7902 1990-12-17 12800 Null 20
7499 Asho Salesman 7698 1991-02-20 13600 1300 30
7521 Sumit Salesman 7698 1991-02-22 15250 1500 30
7566 Jyoti Manager 7839 1991-04-02 14975 Null 20
7654 Martin Salesman 7698 1991-09-28 16250 2400 30
7698 Binod Manager 7839 1991-05-01 15850 Null 30
7782 Chetan Manager 7839 1991-04-19 12450 Null 10
7788 Sudhir Analyst 7566 1997-04-19 15000 Null 20
7839 Kavita President Null 1991-11-17 19000 Null 10
7844 Tushar Salesman 7698 1991-09-08 14500 0 30
7876 Anand Clerk 7788 1997-05-23 16100 Null 20
7900 Jagdeep Clerk 7698 1991-12-03 14900 Null 30
7902 Sumit Analyst 7566 1991-12-03 13500 3600 20
7934 Manoj Clerk 7782 1992-01-03 15300 Null 10
i) SELECT COUNT(*) FROM EMP WHERE DEPTNO=20;
ii) SELECT SUM(COMM) FROM EMP WHERE DEPTNO=30;
iii) SELECT MIN(SAL) FROM EMP WHERE DEPTNO=10;
iv) SELECT AVG(COMM) FROM EMP WHERE COMM<1500;
v) SELECT COUNT(DISTINCT JOB) FROM EMP;
vi) SELECT SUM(SALARY+COMM) FROM EMP WHERE JOB=”MANAGER’;
vii) SELECT CONCAT(ENAME, JOB) FROM EMP WHERE JOB=’ANALYST’;
viii) SELECT MAX(SALARY) FROM EMP WHERE COMM IS NULL;
ix) To display ename,job,salary, hiredate of employees who are hired between May 20,
1990 and December 31, 1991. Order the query in ascending order of the Hiredate.
x) To display all details of the job of post clerk, analyst or manager.

33. You need to display a webpage news.html in response to URL<server>/about/work/ for app
work in your Django project named Headlines. Write the following: (4)

(i) View function namely mywork for work app


(ii) URL configuration for views.mywork.

34.Explain Django Architecture. (3)

You might also like