SQL Test

SQL Test

 

Note:  Upwork SQL Test questions are posted and answers will be updated soon stay with us.


Which of the following query can be used to copy all records from table1 into table2 provided they have same columns?

a. CLONE INTO table2 SELECT * FROM table1;
b. INSERT INTO table1 FROM table2;
c. INSERT INTO table2 FROM table1;
d. INSERT INTO table2 SELECT * FROM table1;


Which of the following statements is true?

a. Select, create are DDL commands.
b. Create, Grant are DCL commands.
c. Drop, Insert are TCL commands.
d. Alter, Drop are DDL commands.


Consider the following Attendance table, which contains employee attendance record for a company:

EmployeeID (int), LoginTime (time), LogoutTime (time)

Which of these SELECT statements will list the employee ID that has logged-in most recently?

a. SELECT EmployeeID
    FROM Attendance
    GROUP BY LoginTime
    HAVING MAX(LoginTime)
b. SELECT TOP 1 a.EmployeeID
    FROM Attendance a
    WHERE EXISTS (SELECT MAX(b.LoginTime) FROM Attendance b GROUP BY EmployeeID HAVING MAX(b.LoginTime) =           a.LoginTime AND a.EmployeeID = b.EmployeeID )
c. SELECT TOP 1 a.EmployeeID
    FROM Attendance a
    WHERE a.LoginTime = (SELECT MAX(b.LoginTime) FROM Attendance b)
d. None of the above


Consider two tables A, and B having only one column each and having these values:

A = [0, 1, 2, 3, 4, 5]
B = [5, 6, 7, 8, 9, 10]

The result of UNION ALL operator on these tables will be?

a. [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
b. [5]
c. [0, 1, 2, 3, 4, 5, 5, 6, 7, 8, 9, 10]
d. None of the above


Consider the following Attendance table which contains employee attendance record for a company:

EmployeeID (int), LoginTime (time), LogoutTime (time)

Which of these SELECT statements will list all the employee IDs that have more than 100 entries in the table?

a. SELECT EmployeeID FROM Attendance WHERE COUNT(1) > 100
b. SELECT EmployeeID FROM Attendance WHERE COUNT(EmployeeID) > 100
c. SELECT EmployeeID FROM Attendance GROUP BY EmployeeID HAVING COUNT(1) > 100
d. None of the above


Which statement is used to delete a table from a database?

a. REMOVE TABLE
b. DROP TABLE
c. DELETE TABLE
d. ERASE TABLE


‘Grant’ is classified as which type of command in SQL?

a. DDL
b. DML
c. DCL
d. All of the above


Which of the following commands is used to explain access to data?

a. EXPLAIN PATH
b. EXPLAIN PLAN
c. CALL
d. EXPLAIN ACCESS


What does MID() function do?

a. Returns the middle character.
b. Extract characters from a text field.
c. Returns the length of a text field.


Which of the following SQL commands can be included to sort data?

a. SORT WITH
b. SORT BY
c. ORDER BY
d. LIST BY


Prev1 of 4

Share This Post