Database Management Systems (3130703) MCQs

MCQs of SQL Concepts

Showing 41 to 50 out of 68 Questions
41.

FIND SQUARE & SQUARE ROOT OF 25.

(a)

SELECT SQUARE (25), SQRT (25)

(b)

SELECT SQUARE (25) AND SQRT (25)

(c)

SELECT SQUAREOF (25), SQRTOF (25)

(d)

SELECT SQUAREOF (25) AND SQRTOF (25)

Answer:

Option (a)

42.

Write SQL statements (Query) for following tables:

Employee(EmpNo, EmpName, JoiningDate, Salary, City)

FIND FIRST 3 CHARACTERS OF EMPLOYEE NAME.

(a)

SELECT LEFTCHAR(EMPNAME,3) FROM EMPLOYEE

(b)

SELECT LEFT(EMPNAME,3) FROM EMPLOYEE

(c)

SELECT LEFT(EMPNAME AND 3) FROM EMPLOYEE

(d)

SELECT LEFTSIDE(EMPNAME,3) FROM EMPLOYEE

Answer:

Option (b)

43.

Write SQL statements (Query) for following tables:

Employee(EmpNo, EmpName, JoiningDate, Salary, City)

FIND EMPLOYEE NAME IN LOWER CASE & CITY IN UPPER CASE.

(a)

SELECT LOWERCHARACTER(EMPNAME), UPPERCHARACTER(CITY) FROM EMPLOYEE

(b)

SELECT LOWERCHAR(EMPNAME), UPPERCHAR(CITY) FROM EMPLOYEE

(c)

SELECT LOWER(EMPNAME), UPPER(CITY) FROM EMPLOYEE

(d)

SELECT LOWERCASE(EMPNAME), UPPERCASE(CITY) FROM EMPLOYEE

Answer:

Option (c)

44.

Write SQL statements (Query) for following tables:

Employee(EmpNo, EmpName, JoiningDate, Salary, City)

FIND ALL THE CITIES WITH LENGTH OF CITY NAME IS 5.

(a)

SELECT CITY FROM EMPLOYEE WHERE LENGHTOFCITY IS 5

(b)

SELECT CITY FROM EMPLOYEE WHERE LENGHTOFCITY = 5

(c)

SELECT CITY FROM EMPLOYEE WHERE LENGTH(CITY) = 5

(d)

SELECT CITY FROM EMPLOYEE WHERE LEN(CITY) = 5

Answer:

Option (d)

45.

Write SQL statements (Query) for following tables:

Employee(EmpNo, EmpName, JoiningDate, Salary, City)

PRODUCE OUTPUT LIKE: <EMPNAME> earns <SALARY> monthly. (In Single Column)

(a)

SELECT EMPNAME+' earns '+CAST (SALARY AS VARCHAR (50))+' monthly' FROM EMPLOYEE

(b)

SELECT EMPNAME+' earns '+CASTED (SALARY AS VARCHAR (50))+' monthly' FROM EMPLOYEE

(c)

SELECT EMPNAME+' earns '+CAST (SALARY VARCHAR (50))+' monthly' FROM EMPLOYEE

(d)

SELECT EMPNAME+' earns '+CAST (SALARY AS VARCHAR (50))+' monthly' INTO EMPLOYEE

Answer:

Option (a)

46.

Write SQL statements (Query) for following tables:

Employee(EmpNo, EmpName, JoiningDate, Salary, City)

PRODUCE OUTPUT LIKE: <EMPNAME> earns <SALARY> monthly. (In Single Column)

(a)

SELECT EMPNAME+ ' earns '+CONVERT (VARCHAR (50), SALARY)+' monthly' INTO EMPLOYEE

(b)

SELECT EMPNAME+ ' earns '+CONVERT (VARCHAR (50 ) OF SALARY)+' monthly' FROM EMPLOYEE

(c)

SELECT EMPNAME+ ' earns '+CONVERTED (VARCHAR (50), SALARY)+' monthly' FROM EMPLOYEE

(d)

SELECT EMPNAME+ ' earns '+CONVERT (VARCHAR (50), SALARY)+' monthly' FROM EMPLOYEE

Answer:

Option (d)

47.

Write SQL statements (Query) for following tables:

Employee(EmpNo, EmpName, JoiningDate, Salary, City)

PRODUCE OUTPUT LIKE: <EMPNAME> earns <SALARY> monthly. (In Single Column)

(a)

SELECT CONCAT (EMPNAME +' earns '+ SALARY+' monthly ') FROM EMPLOYEE

(b)

SELECT CONCAT (EMPNAME,' earns ', SALARY,' monthly ') FROM EMPLOYEE

(c)

SELECT CONCAT (EMPNAME,' earns ', SALARY,' monthly ') INTO EMPLOYEE

(d)

SELECT CONCATENATE (EMPNAME,' earns ', SALARY,' monthly ') FROM EMPLOYEE

Answer:

Option (b)

48.

A table joined with itself is called

(a)

Inner Join

(b)

Self Join

(c)

Outer Join

(d)

Left Outer Join

Answer:

Option (b)

49.

Write SQL statements (Query) for following tables:

Department(DepartmentID (PK), DepartmentName, DepartmentCode, Location)

Person(PeronID (PK), PersonName, DepartmentID (FK), Salary, JoiningDate, City)

Find all persons with their department name & code.

(a)

SELECT [dbo].[Person].*, [dbo].[Department].[DepartmentName], [dbo].[Department].[DepartmentCode]

FROM [dbo].[Person] INNER OUTER JOIN [dbo].[Department]

ON [dbo].[Department].[DepartmentID] = [dbo].[Person].[DepartmentID]

(b)

SELECT [dbo].[Person].*, [dbo].[Department].[DepartmentName], [dbo].[Department].[DepartmentCode]

FROM [dbo].[Person] FULL OUTER JOIN [dbo].[Department]

ON [dbo].[Department].[DepartmentID] = [dbo].[Person].[DepartmentID]

(c)

SELECT [dbo].[Person].*, [dbo].[Department].[DepartmentName], [dbo].[Department].[DepartmentCode]

FROM [dbo].[Person] RIGHT OUTER JOIN [dbo].[Department]

ON [dbo].[Department].[DepartmentID] = [dbo].[Person].[DepartmentID]

(d)

SELECT [dbo].[Person].*, [dbo].[Department].[DepartmentName], [dbo].[Department].[DepartmentCode]

FROM [dbo].[Person] LEFT OUTER JOIN [dbo].[Department]

ON [dbo].[Department].[DepartmentID] = [dbo].[Person].[DepartmentID]

Answer:

Option (d)

50.

Write SQL statements (Query) for following tables:

Department(DepartmentID (PK), DepartmentName, DepartmentCode, Location)

Person(PeronID (PK), PersonName, DepartmentID (FK), Salary, JoiningDate, City)

Give department wise maximum & minimum salary with department name.

(a)

SELECT [dbo].[Department].[DepartmentName], MAX([dbo].[Person].[Salary]) AS Max_Sal, MIN([dbo].[Person].[Salary]) AS Min_Sal

FROM [dbo].[Person]

CROSS JOIN [dbo].[Department]

ON [dbo].[Department].[DepartmentID] = [dbo].[Person].[DepartmentID]

GROUP BY [dbo].[Department].[DepartmentName]

(b)

SELECT [dbo].[Department].[DepartmentName], MAX([dbo].[Person].[Salary]) AS Max_Sal, MIN([dbo].[Person].[Salary]) AS Min_Sal

FROM [dbo].[Person]

LEFT OUTER JOIN [dbo].[Department]

ON [dbo].[Department].[DepartmentID] = [dbo].[Person].[DepartmentID]

GROUP BY [dbo].[Department].[DepartmentName]

(c)

SELECT [dbo].[Department].[DepartmentName], MAX([dbo].[Person].[Salary]) AS Max_Sal, MIN([dbo].[Person].[Salary]) AS Min_Sal

FROM [dbo].[Person]

RIGHT OUTER JOIN [dbo].[Department]

ON [dbo].[Department].[DepartmentID] = [dbo].[Person].[DepartmentID]

GROUP BY [dbo].[Department].[DepartmentName]

(d)

SELECT [dbo].[Department].[DepartmentName], MAX([dbo].[Person].[Salary]) AS Max_Sal, MIN([dbo].[Person].[Salary]) AS Min_Sal

FROM [dbo].[Person]

FULL OUTER JOIN [dbo].[Department]

ON [dbo].[Department].[DepartmentID] = [dbo].[Person].[DepartmentID]

GROUP BY [dbo].[Department].[DepartmentName]

Answer:

Option (b)

Showing 41 to 50 out of 68 Questions