0% found this document useful (0 votes)
3 views

complex-mysql

The document is a MySQL worksheet containing multiple-choice questions (MCQs) and open-ended questions related to SQL concepts and functions. It covers topics such as data types, SQL constraints, differences between SQL clauses, and SQL queries for specific tables. Additionally, it includes practical SQL query exercises based on provided tables and data.

Uploaded by

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

complex-mysql

The document is a MySQL worksheet containing multiple-choice questions (MCQs) and open-ended questions related to SQL concepts and functions. It covers topics such as data types, SQL constraints, differences between SQL clauses, and SQL queries for specific tables. Additionally, it includes practical SQL query exercises based on provided tables and data.

Uploaded by

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

MySQL WORKSHEET

LEVEL-2
I. MCQ
1. Duplication of record is called ___________.
(a) Duplicate
(b) Redundancy
(c) Integrity
(d) Aggregate
2. The month() function in MySql ia an example of_____.
(a) Math Function
(b) Text Function
(c ) Data Function
(c) Aggregate Function
3. Find the output for the following query
SELECT RIGHT(‘SOFTWARE’,2);
(a) RE
(b) WA
(c) OFTWARE
(d) O
4. SELECT ROUND(79.987,2)
(a) 79
(b) 80
(c) 79.99
(d) 79.9
5. SELECT MOD(20,3);
(a) 1
(b) 2
(c) 3
(d) 4
6. SELECT INSTR(‘INFORMATION FORM’,’FOR’);
(a) 3
(b) 12
(c) 13
(d) 2
7. The command ______ can be used to make changes in the rows of a table in SQL.
(a) Alter
(b) Update
(c) Delete
(d) Change
8. Which command can be used to arrange data in some order in a table in SQL.
(a) Group by
(b) Sort
(c) Arrange by
(d) Order by
9. If you want to exclude duplicate values from the aggregate function results, use the _______
keyword.
(a) Primary key
(b) Unique
(c) DISTINCT
(d) COMMON
10. The string function that returns the index of the first occurrence of substring
is______________.
(a) INSERT()
(b) INSTR()
(c) INSRING()
(d) SUBSTR()

II. SECTION-B

1. What is the difference between char and varchar?

2. Explain the following SQL Constraints:

i. NOT NULL
ii. UNIQUE
iii. DEFAULT
iv. PRIMARY KEY

v. FOREIGN KEY

3. What is the difference between cardinality and degree?.


4. Differentiate between WHERE and HAVING clause.

5. Define Primary Key of a relation in SQL. Give an Example using a dummy table.

6. Differentiate between DDL and DML with one Example each.

7. Define RDBMS. Name any two RDBMS software.

8. Write any two differences between Single_row functions and Aggregate functions.
III. SECTION- C
1. Write SQL queries for the following :

Table : STIPEND

S_id Name Amount Subject Percentage Position


1 Anuj 4000 English 65 P1
2 Ashu 4500 History 60 P2
3 Ruby 3500 English 55 P2
4 Raman 3800 Math 58 P3
SQL Queries

a. Display the names of those students who has Position ‘P1’ sorted by NAME.

b. Display Name, Subject and Amount received in a year (as Annual Amount) assuming that
monthly amount is given in table.

c. Count the number of students whose percentage is less than 60.

d. Display the different subjects from the table.

e. Display the detail of student whose name ends with ‘j’

f. Display the subject wise amount paid.


Give the output of following SQL statement based on table STIPEND:

(i) Select MIN(Percentage) from Stipend where Subject=”English”;

(ii) Select SUM(Amount) from Stipend WHERE Position = ‘P2’;

(iii) Select AVG(Amount) from Stipend where Percentage>=60;

(iv) Select COUNT(distinct (SUBJECT)) from Stipend;

2. Write outputs for SQL queries which are based on the given table GARMENT:

i. SELECT GNAME, COLOUR FROM GARMENT WHERE SIZE = "M";


ii. SELECT GNAME, COLOUR FROM GARMENT WHERE PRICE > = 3000;
iii. SELECT PRICE FROM GARMENT WHERE COLOUR = "Blue";
3. Write the SQL functions which will perform the following operations:

i) To display the month name of the current date

ii) To remove leading spaces from the string,“ PYTHON“.

iii) To display the current date.

iv) To display your name in upper case.

v) To compute the remainder of division between two numbers, n1 and n2.

4. Consider a table SALES with the following data:

TABLE: SALES
Write SQL queries using SQL functions to perform the following operations:

i. Display the name of salesman in lower case.

ii. Display the year name for the date of join of salesman.

iii. Display the name of the weekday for the date of join of salesman whose month is 12.

iv. Display the highest salary of salesman having name length more than 15 and who gets bonus.

*********

You might also like