Software Development Exam  >  Software Development Tests  >  Test: SQL Server - 2 - Software Development MCQ

Test: SQL Server - 2 - Software Development MCQ


Test Description

15 Questions MCQ Test - Test: SQL Server - 2

Test: SQL Server - 2 for Software Development 2024 is part of Software Development preparation. The Test: SQL Server - 2 questions and answers have been prepared according to the Software Development exam syllabus.The Test: SQL Server - 2 MCQs are made for Software Development 2024 Exam. Find important definitions, questions, notes, meanings, examples, exercises, MCQs and online tests for Test: SQL Server - 2 below.
Solutions of Test: SQL Server - 2 questions in English are available as part of our course for Software Development & Test: SQL Server - 2 solutions in Hindi for Software Development course. Download more important topics, notes, lectures and mock test series for Software Development Exam by signing up for free. Attempt Test: SQL Server - 2 | 15 questions in 30 minutes | Mock test for Software Development preparation | Free important questions MCQ to study for Software Development Exam | Download free PDF with solutions
Test: SQL Server - 2 - Question 1

Which of the following is not a valid data type in SQL?

Detailed Solution for Test: SQL Server - 2 - Question 1

BOOLEAN is not a valid data type in SQL Server. The valid data types in SQL Server include VARCHAR, INT, FLOAT, and others, but BOOLEAN is not among them.

Test: SQL Server - 2 - Question 2

Which SQL statement is used to retrieve data from a database?

Detailed Solution for Test: SQL Server - 2 - Question 2

The SELECT statement is used to retrieve data from a database. It allows you to specify the columns to be selected and the table(s) from which to retrieve the data.

1 Crore+ students have signed up on EduRev. Have you? Download the App
Test: SQL Server - 2 - Question 3

Which SQL statement is used to modify existing data in a database?

Detailed Solution for Test: SQL Server - 2 - Question 3

The UPDATE statement is used to modify existing data in a database. It allows you to update specific columns or rows in a table based on specified conditions.

Test: SQL Server - 2 - Question 4

Which SQL statement is used to delete data from a database?

Detailed Solution for Test: SQL Server - 2 - Question 4

The DELETE statement is used to delete data from a database. It allows you to delete specific rows from a table based on specified conditions.

Test: SQL Server - 2 - Question 5

What is the purpose of the GROUP BY clause in SQL?

Detailed Solution for Test: SQL Server - 2 - Question 5

The GROUP BY clause in SQL is used to group rows based on a specified column or columns. It is often used in conjunction with aggregate functions such as SUM, AVG, COUNT, etc.

Test: SQL Server - 2 - Question 6

Consider the following SQL code:

CREATE TABLE Employees (
  EmployeeID INT PRIMARY KEY,
  FirstName VARCHAR(50),
  LastName VARCHAR(50)
);

INSERT INTO Employees (EmployeeID, FirstName, LastName)
VALUES (1, 'John', 'Doe');

SELECT * FROM Employees;

What is the output of the above code?

Detailed Solution for Test: SQL Server - 2 - Question 6

The code creates a table named "Employees" with three columns: EmployeeID, FirstName, and LastName. It then inserts a single row into the table with values (1, 'John', 'Doe'). Finally, it selects all rows from the Employees table, which will return the inserted row: 1, 'John', 'Doe'.

Test: SQL Server - 2 - Question 7

Consider the following SQL code:

CREATE TABLE Students (
  StudentID INT PRIMARY KEY,
  Name VARCHAR(50),
  Age INT
);

INSERT INTO Students (StudentID, Name, Age)
VALUES (1, 'Alice', 20),
       (2, 'Bob', 22),
       (3, 'Charlie', 21);

SELECT COUNT(*) FROM Students;
What is the output of the above code?

Detailed Solution for Test: SQL Server - 2 - Question 7

The code creates a table named "Students" with three columns: StudentID, Name, and Age. It then inserts three rows into the table. The SELECT statement with COUNT(*) returns the total number of rows in the Students table, which is 3.

Test: SQL Server - 2 - Question 8

Consider the following SQL code:

CREATE TABLE Orders (
  OrderID INT PRIMARY KEY,
  CustomerID INT,
  TotalAmount DECIMAL(10, 2),
  OrderDate DATE
);

INSERT INTO Orders (OrderID, CustomerID, TotalAmount, OrderDate)
VALUES (1, 101, 100.50, '2023-05-01'),
       (2, 102, 200.75, '2023-05-02'),
       (3, 103, 150.20, '2023-05-03');

SELECT MAX(TotalAmount) FROM Orders;

What is the output of the above code?

Detailed Solution for Test: SQL Server - 2 - Question 8

The code creates a table named "Orders" with four columns: OrderID, CustomerID, TotalAmount, and OrderDate. It then inserts three rows into the table. The SELECT statement with MAX(TotalAmount) returns the maximum value of the TotalAmount column, which is 200.75.

Test: SQL Server - 2 - Question 9

Consider the following SQL code:

CREATE TABLE Employees (
  EmployeeID INT PRIMARY KEY,
  FirstName VARCHAR(50),
  LastName VARCHAR(50)
);

INSERT INTO Employees (EmployeeID, FirstName, LastName)
VALUES (1, 'John', 'Doe'),
       (2, 'Jane', 'Smith'),
       (3, 'Alice', 'Johnson');

SELECT FirstName FROM Employees WHERE LastName = 'Smith';
What is the output of the above code?

Detailed Solution for Test: SQL Server - 2 - Question 9

The code creates a table named "Employees" with three columns: EmployeeID, FirstName, and LastName. It then inserts three rows into the table. The SELECT statement with WHERE clause filters rows where LastName is 'Smith'. However, there is no row with LastName 'Smith' in the table, so it will result in an empty result set or an error depending on the database configuration.

Test: SQL Server - 2 - Question 10

Consider the following SQL code:

CREATE TABLE Products (
  ProductID INT PRIMARY KEY,
  ProductName VARCHAR(50),
  UnitPrice DECIMAL(10, 2),
  UnitsInStock INT
);

INSERT INTO Products (ProductID, ProductName, UnitPrice, UnitsInStock)
VALUES (1, 'Keyboard', 29.99, 100),
       (2, 'Mouse', 19.99, 50),
       (3, 'Monitor', 199.99, 10);

SELECT SUM(UnitPrice * UnitsInStock) FROM Products;
What is the output of the above code?

Detailed Solution for Test: SQL Server - 2 - Question 10

The code creates a table named "Products" with four columns: ProductID, ProductName, UnitPrice, and UnitsInStock. It then inserts three rows into the table. The SELECT statement with SUM(UnitPrice * UnitsInStock) calculates the total value of all products by multiplying the UnitPrice and UnitsInStock columns for each row and summing them up. The result is 3499.00.

Test: SQL Server - 2 - Question 11

Consider the following SQL code:

CREATE TABLE Employees (
  EmployeeID INT PRIMARY KEY,
  FirstName VARCHAR(50),
  LastName VARCHAR(50),
  DepartmentID INT
);

INSERT INTO Employees (EmployeeID, FirstName, LastName, DepartmentID)
VALUES (1, 'John', 'Doe', 101),
       (2, 'Jane', 'Smith', 102),
       (3, 'Alice', 'Johnson', 101);

SELECT DepartmentID, COUNT(*) FROM Employees GROUP BY DepartmentID;
What is the output of the above code?

Detailed Solution for Test: SQL Server - 2 - Question 11

The code creates a table named "Employees" with four columns: EmployeeID, FirstName, LastName, and DepartmentID. It then inserts three rows into the table. The SELECT statement with GROUP BY DepartmentID counts the number of employees in each department. In this case, there are 2 employees in department 101 and 1 employee in department 102.

Test: SQL Server - 2 - Question 12

Consider the following SQL code:

CREATE TABLE Students (
  StudentID INT PRIMARY KEY,
  Name VARCHAR(50),
  Marks INT
);

INSERT INTO Students (StudentID, Name, Marks)
VALUES (1, 'Alice', 90),
       (2, 'Bob', 80),
       (3, 'Charlie', 95);

SELECT AVG(Marks) FROM Students;

What is the output of the above code?

Detailed Solution for Test: SQL Server - 2 - Question 12

The code creates a table named "Students" with three columns: StudentID, Name, and Marks. It then inserts three rows into the table. The SELECT statement with AVG(Marks) calculates the average value of the Marks column, which is (90 + 80 + 95) / 3 = 88.33.

Test: SQL Server - 2 - Question 13

Consider the following SQL code:

CREATE TABLE Orders (
  OrderID INT PRIMARY KEY,
  CustomerID INT,
  TotalAmount DECIMAL(10, 2),
  OrderDate DATE
);

INSERT INTO Orders (OrderID, CustomerID, TotalAmount, OrderDate)
VALUES (1, 101, 100.50, '2023-05-01'),
       (2, 102, 200.75, '2023-05-02'),
       (3, 103, 150.20, '2023-05-03');

SELECT CustomerID, SUM(TotalAmount) FROM Orders GROUP BY CustomerID;
What is the output of the above code?

Detailed Solution for Test: SQL Server - 2 - Question 13

The code creates a table named "Orders" with four columns: OrderID, CustomerID, TotalAmount, and OrderDate. It then inserts three rows into the table. The SELECT statement with GROUP BY CustomerID calculates the sum of TotalAmount for each customer. In this case, the output will include the customer ID and the corresponding sum of TotalAmount for each customer.

Test: SQL Server - 2 - Question 14

Consider the following SQL code:

CREATE TABLE Orders (
  OrderID INT PRIMARY KEY,
  CustomerID INT,
  TotalAmount DECIMAL(10, 2),
  OrderDate DATE
);

INSERT INTO Orders (OrderID, CustomerID, TotalAmount, OrderDate)
VALUES (1, 101, 100.50, '2023-05-01'),
       (2, 102, 200.75, '2023-05-02'),
       (3, 103, 150.20, '2023-05-03');

SELECT CustomerID, SUM(TotalAmount) FROM Orders GROUP BY CustomerID;
What is the output of the above code?

Detailed Solution for Test: SQL Server - 2 - Question 14

The code creates a table named "Employees" with four columns: EmployeeID, FirstName, LastName, and Salary. It then inserts three rows into the table. The SELECT statement with WHERE clause filters rows where Salary is greater than 60000.00. In this case, it will return the row with 'Alice' as the FirstName and 70000.00 as the Salary.

Test: SQL Server - 2 - Question 15

Consider the following SQL code:

CREATE TABLE Products (
  ProductID INT PRIMARY KEY,
  ProductName VARCHAR(50),
  UnitPrice DECIMAL(10, 2),
  UnitsInStock INT
);

INSERT INTO Products (ProductID, ProductName, UnitPrice, UnitsInStock)
VALUES (1, 'Keyboard', 29.99, 100),
       (2, 'Mouse', 19.99, 50),
       (3, 'Monitor', 199.99, 10);

SELECT ProductName FROM Products ORDER BY UnitPrice DESC;
What is the output of the above code?

Detailed Solution for Test: SQL Server - 2 - Question 15

The code creates a table named "Products" with four columns: ProductID, ProductName, UnitPrice, and UnitsInStock. It then inserts three rows into the table. The SELECT statement with ORDER BY UnitPrice DESC sorts the rows in descending order based on the UnitPrice column. Therefore, the output will be 'Monitor', 'Mouse', 'Keyboard' as the ProductName values in that order.

Information about Test: SQL Server - 2 Page
In this test you can find the Exam questions for Test: SQL Server - 2 solved & explained in the simplest way possible. Besides giving Questions and answers for Test: SQL Server - 2, EduRev gives you an ample number of Online tests for practice

Top Courses for Software Development

Download as PDF

Top Courses for Software Development