C# - C Sharp: DBI202 - PT1


Khóa học qua video:
Lập trình Python All Lập trình C# All SQL Server All Lập trình C All Java PHP HTML5-CSS3-JavaScript
Đăng ký Hội viên
Tất cả các video dành cho hội viên

(nhấn nút 'Result' để biết kết quả)

Q1: In a query that retrieves data from two tables that have been called joined together, the result returned includes only the records in the right table. Identify the type of join used in the above query?
Outer Join
Right Outer Join
Full Join
Right Inner join

Q2: How do you retrieve all columns from a table?
Select all
Select *
Select columns
Select all columns

Q3: Which keyword sorts data in descending order?
order
reverse
desc
asc

Q4: What will the following query return?
  SELECT COUNT(*) FROM Employees WHERE Age > 30;
All employees
Number of employees older than 30
Employees younger than 30
Average age

Q5: When you want to delete the Books table in the database, which of the following syntax is used?
DROP Books
DROP TABLE Books FROM library
DROP TABLE Books
DELETE TABLE Books
DELETE TABLE Books FROM library

Q6: What is the correct way to alias a column in SQL Server?
SELECT name = employee_name
SELECT name -> employee_name
SELECT name AS employee_name
SELECT name TO employee_name

Q7: What keyword is used to modify existing records?
ALTER
UPDATE
MODIFY
CHANGE

Q8: What is a PRIMARY KEY used for?
To allow duplicates
To reference another table
To increase performance
To uniquely identify a record

Q9: Which of the following statements is true about the COUNT function? (choose 3)
When using the COUNT function on a primary key field, it always returns correct results because the primary key field does not have null values.
When used in combination with the DISTINCT keyword, the COUNT function counts only distinct values.
The syntax of the COUNT function only works on fields with numeric data type.
The syntax of the COUNT function is COUNT(Expression)
Using the COUNT function on a foreign key field may return incorrect results because the foreign key field may have null values.

10: DML stands for
Data Moulding Language
Data Manipulation Language
Data Modeling Language
Data Marketing Language

Q11: What is a FOREIGN KEY?
A key from a different database
A random identifier
A key that references a primary key in another table
A key stored externally

Q12: Which constraint ensures all values in a column are unique?
NOT NULL
UNIQUE
KEY
DEFAULT

Q13: What is the default behavior of PRIMARY KEY regarding NULLs?
Does not allow NULLs
Allows multiple NULLs
Allows one NULL
Converts NULLs to 0

Q14: Which of the following statements is true about Join?
Join can be used in the FROM clause. In queries with a WHERE clause, Join cannot be used.
In SQL Server 2005 tables are joined together based on relationships between those tables.
Join shows the relationship between 2 tables
When used, Join eliminates the concept of foreign key relationships between tables.
Join can only be used on 2 tables

Q15: How do you define a column with a default value of 'USA'?
Country SET 'USA'
Country DEFAULT 'USA'
DEFAULT 'USA' ON Country
DEFAULT Country = 'USA'

Q16: Which of the following statements is false? (choose 2)
Outer joins will return all records of a certain table in the FROM clause, if those records satisfy the conditions in the WHERE and HAVING clauses.
There are 4 types of outer joins
Inner Hoins returns all records even if there is no corresponding record in the related table.
Inner hoins remove records that have no corresponding records in the related table.

Q17: Determine the correct syntax for LEFT OUTER JOIN
LEFT OUTER TABLE SELECT <Field_List> from <First_table><Second_table> ON
   First_Table.<common_Field>=Second_Table.<common_Field>
SELECT <Field_List> from <First_table> LEFT OUTER TABLE <Second_table> ON
   First_Table.<common_Field>=Second_Table.<common_Field>
SELECT <Field_List> from <First_table> LEFT OUTER JOIN <Second_table> ON
   First_Table.<common_Field>=Second_Table.<common_Field>
SELECT <Field_List> from <First_table> LEFT OUTER JOIN <Second_table> WHERE
   First_Table.<common_Field>=Second_Table.<common_Field>

Q18: What is the purpose of `GROUP BY`?
To join tables
To summarize data into groups
To delete duplicate rows
To restrict columns

Q19: What is the difference between `WHERE` and `HAVING`?
Both filter columns only
`WHERE` filters rows, `HAVING` filters groups
`HAVING` is used with INSERT
`WHERE` is used after GROUP BY

Q20: Which clause comes after `GROUP BY` in a valid query?
ORDER BY
HAVING
DISTINCT
WHERE

Q21: What does the COUNT(*) function do?
Returns the number of columns
Returns the number of rows
Returns total table size
Counts primary keys

Q22: Find the correct statement
  Statement 1 – Tables are created to store entities
  Statement 2 – Fields are created to represent attributes of the entity
Statement 2 is correct
Statement 1 is correct
Both statements are correct
None of the statements are correct

Q23: What will this query return?
  SELECT Department, COUNT(*) FROM Employees GROUP BY Department;
Total rows
Number of employees per department
Average salary
List of departments

Q24: Which clause is invalid in this order:
  SELECT ...  
  FROM ...  
  GROUP BY ...  
  WHERE ...
SELECT
WHERE
GROUP BY
FROM

Q25: How to return only departments with more than 5 employees?
WHERE COUNT(*) > 5
HAVING COUNT(*) > 5
GROUP COUNT(*) > 5
FILTER COUNT(*) > 5

Q26: Which SQL statement correctly creates a table where EmployeeID automatically increases starting from 1?
A. CREATE TABLE Employee(EmployeeID INT AUTO, Name VARCHAR(50))
B. CREATE TABLE Employee(EmployeeID INT IDENTITY(1,1), Name VARCHAR(50))
C. CREATE TABLE Employee(EmployeeID NUMBER IDENTITY, Name VARCHAR(50))
D. CREATE TABLE Employee(EmployeeID SERIAL, Name VARCHAR(50))

Q27: Which statement inserts multiple rows into a table in a single SQL command?
A. INSERT INTO Student VALUES (1,'Tom'), (2,'Jerry')
B. ADD INTO Student VALUES (1,'Tom'), (2,'Jerry')
C. INSERT ROW Student (1,'Tom'), (2,'Jerry')
D. APPEND INTO Student VALUES (1,'Tom'), (2,'Jerry')

Q28: Which UPDATE statement increases every employee's salary by 8%?
A. UPDATE Employee SET Salary = Salary * 1.08
B. UPDATE Employee Salary = Salary * 1.08
C. MODIFY Employee SET Salary = Salary * 1.08
D. CHANGE Employee SET Salary = Salary * 1.08

Q29: Which DELETE statement removes employees hired before January 1, 2020?
A. DELETE Employee WHERE HireDate < '2020-01-01'
B. DELETE FROM Employee WHERE HireDate < '2020-01-01'
C. REMOVE FROM Employee WHERE HireDate < '2020-01-01'
D. DROP FROM Employee WHERE HireDate < '2020-01-01'

Q30: Which query returns only unique combinations of City and Country?
A. SELECT UNIQUE City, Country FROM Customer
B. SELECT DISTINCT City, Country FROM Customer
C. SELECT SINGLE City, Country FROM Customer
D. SELECT ONLY City, Country FROM Customer

Q31: Which JOIN returns all departments even if they have no employees?
A. INNER JOIN
B. RIGHT JOIN Employee → Department
C. LEFT JOIN Department → Employee
D. CROSS JOIN

Q32: Which GROUP BY query calculates the average salary for each department?
A. SELECT DepartmentID, AVG(Salary) FROM Employee GROUP BY DepartmentID
B. SELECT AVG(Salary) GROUP DepartmentID FROM Employee
C. SELECT DepartmentID GROUP BY AVG(Salary)
D. SELECT DepartmentID, Salary GROUP BY AVG()

Q33: Which ORDER BY clause sorts salary from lowest to highest and name alphabetically for equal salaries?
A. ORDER BY Salary ASC, Name ASC
B. ORDER BY Salary DESC, Name ASC
C. ORDER Salary ASC, Name ASC
D. SORT BY Salary, Name

Q34: Which query returns the five highest-paid employees in SQL Server?
A. SELECT LIMIT 5 * FROM Employee ORDER BY Salary DESC
B. SELECT TOP 5 * FROM Employee ORDER BY Salary DESC
C. SELECT FIRST 5 * FROM Employee ORDER BY Salary DESC
D. SELECT MAX 5 * FROM Employee ORDER BY Salary DESC

Q35: Which aggregate function counts only non-NULL values in the Email column?
A. COUNT(*)
B. COUNT(Email)
C. SUM(Email)
D. TOTAL(Email)

Q36: Which function returns the quarter number of a given date in SQL Server?
A. QUARTER(DateValue)
B. DATEPART(QUARTER, DateValue)
C. MONTHPART(DateValue)
D. GETQUARTER(DateValue)

Q37: Which function returns the absolute value of -245?
A. ABS(-245)
B. MOD(-245)
C. ROUND(-245)
D. SIGN(-245)

Q38: Which string function converts all characters in a column to lowercase?
A. LOWER(ColumnName)
B. SMALL(ColumnName)
C. LCASEONLY(ColumnName)
D. MINCASE(ColumnName)

Q39: Which constraint ensures that every value in the PhoneNumber column is different?
A. DEFAULT
B. CHECK
C. UNIQUE
D. FOREIGN KEY

Q40: Which PRIMARY KEY definition is valid for a table with StudentID and CourseID forming a composite key?
A. PRIMARY KEY(StudentID)
B. PRIMARY KEY(StudentID, CourseID)
C. PRIMARY(StudentID, CourseID)
D. KEY PRIMARY(StudentID, CourseID)

Q41: Which FOREIGN KEY definition correctly references Department(DepartmentID)?
A. FOREIGN KEY (DepartmentID) REFERENCES Department(DepartmentID)
B. FOREIGN DepartmentID REFERENCES DepartmentID
C. REFERENCE Department(DepartmentID)
D. FOREIGN REFERENCES DepartmentID

Q42: Which CASE expression classifies salaries greater than or equal to 3000 as 'High' and others as 'Low'?
A. CASE Salary >=3000 THEN 'High' ELSE 'Low' END
B. CASE WHEN Salary >=3000 THEN 'High' ELSE 'Low' END
C. WHEN Salary >=3000 CASE 'High' ELSE 'Low'
D. IF Salary >=3000 THEN 'High'

Q43: Which query finds the maximum order amount for each customer?
A. SELECT CustomerID, MAX(Amount) FROM Orders GROUP BY CustomerID
B. SELECT MAX(CustomerID,Amount) FROM Orders
C. SELECT CustomerID, Amount GROUP MAX()
D. SELECT CustomerID MAX Amount FROM Orders

Q44: Which function returns the number of characters in the string 'Database'?
A. LEN('Database')
B. SIZE('Database')
C. COUNTCHAR('Database')
D. LENGTHOF('Database')

Q45: Which query displays product names sorted by category ascending and price descending?
A. ORDER BY Category ASC, Price DESC
B. ORDER BY Category DESC, Price ASC
C. ORDER Category ASC Price DESC
D. SORT BY Category, Price DESC

Q46: Which SQL function returns the current system date and time in SQL Server?
A. TODAY()
B. GETDATE()
C. CURRENT()
D. NOW()

Q47: Which query returns all employees whose names start with the letter 'A'?
A. SELECT * FROM Employee WHERE Name LIKE 'A%'
B. SELECT * FROM Employee WHERE Name = 'A%'
C. SELECT * FROM Employee WHERE Name IN ('A')
D. SELECT * FROM Employee WHERE Name STARTS 'A'

Q48: Which aggregate function calculates the total value of all orders?
A. COUNT()
B. SUM()
C. AVG()
D. MAX()

Q49: Which statement adds a CHECK constraint to ensure Age is at least 18?
A. CHECK (Age >= 18)
B. VERIFY (Age >= 18)
C. VALIDATE (Age >= 18)
D. LIMIT (Age >= 18)

Q50: Which query returns the first three records after sorting by HireDate ascending?
A. SELECT TOP 3 * FROM Employee ORDER BY HireDate ASC
B. SELECT FIRST 3 * FROM Employee ORDER BY HireDate ASC
C. SELECT LIMIT 3 * FROM Employee ORDER BY HireDate ASC
D. SELECT * TOP 3 Employee ORDER BY HireDate ASC

Q51: Which function extracts the month number from a date?
A. YEAR()
B. MONTH()
C. DATE()
D. WEEK()

Q52: Which query returns departments having more than 10 employees?
A. SELECT DepartmentID FROM Employee GROUP BY DepartmentID HAVING COUNT(*) > 10
B. SELECT DepartmentID FROM Employee WHERE COUNT(*) > 10
C. SELECT DepartmentID HAVING COUNT(*) > 10
D. SELECT COUNT(*) FROM Employee WHERE DepartmentID > 10

Q53: Which string function removes spaces from both ends of a string in SQL Server 2017+?
A. STRIP()
B. TRIM()
C. REMOVE()
D. CLEAN()

Q54: Which JOIN returns only rows with matching values in both tables?
A. LEFT JOIN
B. RIGHT JOIN
C. INNER JOIN
D. FULL JOIN

Q55: Which CASE expression categorizes scores below 50 as 'Fail' and others as 'Pass'?
A. CASE WHEN Score < 50 THEN 'Fail' ELSE 'Pass' END
B. IF Score < 50 THEN 'Fail'
C. CASE Score < 50 = 'Fail'
D. WHEN Score < 50 THEN 'Fail'

Q56: Which function rounds 25.678 to one decimal place?
A. CEILING(25.678)
B. FLOOR(25.678)
C. ROUND(25.678,1)
D. ABS(25.678)

Q57: Which query retrieves employees whose salary is between 3000 and 5000?
A. SELECT * FROM Employee WHERE Salary BETWEEN 3000 AND 5000
B. SELECT * FROM Employee WHERE Salary IN 3000 TO 5000
C. SELECT * FROM Employee WHERE Salary >=3000 OR <=5000
D. SELECT * FROM Employee WHERE Salary RANGE 3000,5000

Q58: Which constraint prevents NULL values in a column?
A. UNIQUE
B. NOT NULL
C. DEFAULT
D. CHECK

Q59: Which query counts the number of distinct job titles?
A. SELECT COUNT(JobTitle) FROM Employee
B. SELECT COUNT(DISTINCT JobTitle) FROM Employee
C. SELECT DISTINCT COUNT(JobTitle) FROM Employee
D. SELECT UNIQUE COUNT(JobTitle) FROM Employee

Q60: Which SQL function concatenates two strings in SQL Server?
A. CONCAT(FirstName, LastName)
B. JOINTEXT(FirstName, LastName)
C. APPEND(FirstName, LastName)
D. MERGE(FirstName, LastName)

Q61: Which SQL function returns the number of days between two dates in SQL Server?
A. DATEDIFF(DAY, StartDate, EndDate)
B. DATEPART(DAY, StartDate, EndDate)
C. DAYDIFF(StartDate, EndDate)
D. DIFFDAY(StartDate, EndDate)

Q62: Which query returns employees whose names end with the letter 'n'?
A. SELECT * FROM Employee WHERE Name LIKE '%n'
B. SELECT * FROM Employee WHERE Name LIKE 'n%'
C. SELECT * FROM Employee WHERE Name = '%n'
D. SELECT * FROM Employee WHERE Name ENDSWITH 'n'

Q63: Which SQL Server function adds 15 days to a given date?
A. DATEADD(DAY,15,OrderDate)
B. ADDDATE(OrderDate,15)
C. DATEPLUS(OrderDate,15)
D. DAYADD(OrderDate,15)

Q64: Which function returns the largest integer less than or equal to 18.9?
A. CEILING(18.9)
B. FLOOR(18.9)
C. ROUND(18.9,0)
D. ABS(18.9)

Q65: Which query replaces NULL values in the Bonus column with 0?
A. SELECT ISNULL(Bonus,0) FROM Employee
B. SELECT NULL(Bonus,0) FROM Employee
C. SELECT IFNULL(Bonus,0) FROM Employee
D. SELECT BONUSNULL(Bonus,0) FROM Employee

Q66: Which query returns the first four characters of ProductName?
A. SELECT LEFT(ProductName,4)
B. SELECT FIRST(ProductName,4)
C. SELECT SUBLEFT(ProductName,4)
D. SELECT START(ProductName,4)

Q67: Which query returns the last three characters of ProductCode?
A. SELECT END(ProductCode,3)
B. SELECT LAST(ProductCode,3)
C. SELECT RIGHT(ProductCode,3)
D. SELECT SUBSTRING(ProductCode,-3)

Q68: Which function returns the position of the first occurrence of '@' in an email address?
A. CHARINDEX('@',Email)
B. POSITION('@',Email)
C. LOCATEFIRST('@',Email)
D. FIND('@',Email)

Q69: Which query replaces every '-' with '/' in a date string?
A. SELECT REPLACE(DateText,'-','/')
B. SELECT CHANGE(DateText,'-','/')
C. SELECT MODIFY(DateText,'-','/')
D. SELECT SWAP(DateText,'-','/')

Q70: Which query returns the first 10 rows after sorting ProductName alphabetically?
A. SELECT TOP 10 * FROM Product ORDER BY ProductName ASC
B. SELECT FIRST 10 * FROM Product ORDER BY ProductName ASC
C. SELECT LIMIT 10 * FROM Product ORDER BY ProductName ASC
D. SELECT * TOP 10 Product ORDER BY ProductName ASC

Q71: Which aggregate function ignores NULL values when calculating the average?
A. AVG()
B. COUNT()
C. SUM()
D. MAX()

Q72: Which query returns only departments whose average salary exceeds 6000?
A. SELECT DepartmentID FROM Employee WHERE AVG(Salary)>6000
B. SELECT DepartmentID,AVG(Salary) FROM Employee GROUP BY DepartmentID HAVING AVG(Salary)>6000
C. SELECT AVG(Salary) FROM Employee HAVING DepartmentID
D. SELECT DepartmentID GROUP AVG(Salary)

Q73: Which SQL statement removes every row from a table but keeps its structure?
A. DROP TABLE Employee
B. DELETE FROM Employee
C. REMOVE Employee
D. ERASE TABLE Employee

Q74: Which query converts a decimal value to an integer data type?
A. CAST(Price AS INT)
B. CHANGE(Price AS INT)
C. MODIFY(Price AS INT)
D. ALTER(Price AS INT)

Q75: Which query uses CASE WHEN to display 'Adult' for Age 18 or above and 'Minor' otherwise?
A. CASE Age>=18 THEN 'Adult' ELSE 'Minor' END
B. CASE WHEN Age>=18 THEN 'Adult' ELSE 'Minor' END
C. IF Age>=18 'Adult' ELSE 'Minor'
D. WHEN Age>=18 CASE 'Adult'

Q76: Which constraint automatically assigns 1 to the Status column if no value is supplied?
A. DEFAULT(1)
B. CHECK(1)
C. UNIQUE(1)
D. NOT NULL(1)

Q77: Which query returns all records except those with NULL values in ManagerID?
A. SELECT * FROM Employee WHERE ManagerID <> NULL
B. SELECT * FROM Employee WHERE ManagerID IS NOT NULL
C. SELECT * FROM Employee WHERE NOT NULL ManagerID
D. SELECT * FROM Employee WHERE ManagerID != NULL

Q78: Which query counts the total number of rows in the Orders table, including rows containing NULL values?
A. SELECT COUNT(*) FROM Orders
B. SELECT COUNT(OrderID) FROM Orders
C. SELECT TOTAL(*) FROM Orders
D. SELECT SUM(*) FROM Orders

Q79: Which query extracts characters 3 through 6 from CustomerName?
A. SELECT SUBSTRING(CustomerName,3,4)
B. SELECT MID(CustomerName,3,6)
C. SELECT LEFT(CustomerName,3,6)
D. SELECT RIGHT(CustomerName,3,4)

Q80: Which JOIN returns all rows from both tables whether matching or not?
A. INNER JOIN
B. LEFT JOIN
C. RIGHT JOIN
D. FULL OUTER JOIN

Q81: Which SQL Server function returns the current year from the system date?
A. YEAR(GETDATE())
B. DATEPART(GETDATE(),YEAR)
C. GETYEAR()
D. CURRENTYEAR()

Q82: Which query returns employees whose LastName contains the text 'son' anywhere in the value?
A. SELECT * FROM Employee WHERE LastName LIKE '%son%'
B. SELECT * FROM Employee WHERE LastName = '%son%'
C. SELECT * FROM Employee WHERE LastName IN ('son')
D. SELECT * FROM Employee WHERE LastName START WITH 'son'

Q83: Which query returns the minimum salary for each department?
A. SELECT DepartmentID, MIN(Salary) FROM Employee GROUP BY DepartmentID
B. SELECT MIN(DepartmentID, Salary) FROM Employee
C. SELECT DepartmentID, Salary MIN() FROM Employee
D. SELECT DepartmentID GROUP Salary

Q84: Which query converts all letters in ProductName to uppercase?
A. SELECT UPPER(ProductName)
B. SELECT CAPITAL(ProductName)
C. SELECT TOUPPER(ProductName)
D. SELECT LARGE(ProductName)

Q85: Which query returns the weekday number of OrderDate?
A. SELECT DATEPART(WEEKDAY, OrderDate)
B. SELECT WEEKDAY(OrderDate, DATEPART)
C. SELECT DAYPART(WEEKDAY, OrderDate)
D. SELECT WEEK(OrderDate)

Q86: Which query replaces NULL values in Commission with Salary * 0.1?
A. SELECT ISNULL(Commission, Salary*0.1) FROM Employee
B. SELECT NULL(Commission, Salary*0.1) FROM Employee
C. SELECT REPLACE(Commission, Salary*0.1) FROM Employee
D. SELECT DEFAULT(Commission, Salary*0.1) FROM Employee

Q87: Which query returns customers ordered by Country ascending and City descending?
A. SELECT * FROM Customer ORDER BY Country ASC, City DESC
B. SELECT * FROM Customer ORDER BY Country DESC, City ASC
C. SELECT * FROM Customer SORT BY Country, City
D. SELECT * FROM Customer ORDER Country ASC, City DESC

Q88: Which query returns the square root of the value stored in Score?
A. SELECT SQRT(Score)
B. SELECT ROOT(Score)
C. SELECT SQUARE(Score)
D. SELECT POWERROOT(Score)

Q89: Which constraint ensures that Quantity is always greater than zero?
A. CHECK (Quantity > 0)
B. DEFAULT (Quantity > 0)
C. UNIQUE (Quantity > 0)
D. NOT NULL (Quantity > 0)

Q90: Which query returns employees whose DepartmentID is either 2, 4, or 6?
A. SELECT * FROM Employee WHERE DepartmentID IN (2,4,6)
B. SELECT * FROM Employee WHERE DepartmentID BETWEEN (2,4,6)
C. SELECT * FROM Employee WHERE DepartmentID = (2,4,6)
D. SELECT * FROM Employee WHERE DepartmentID LIKE (2,4,6)

Q91: Which query returns the number of different cities in the Customer table?
A. SELECT COUNT(DISTINCT City) FROM Customer
B. SELECT DISTINCT COUNT(City) FROM Customer
C. SELECT COUNT(City DISTINCT) FROM Customer
D. SELECT UNIQUE COUNT(City) FROM Customer

Q92: Which query converts the value of BirthDate to the DATE data type?
A. SELECT CAST(BirthDate AS DATE)
B. SELECT CHANGE(BirthDate AS DATE)
C. SELECT MODIFY(BirthDate AS DATE)
D. SELECT ALTER(BirthDate AS DATE)

Q93: Which query returns only products whose price is greater than the average price of all products?
A. SELECT * FROM Product WHERE Price > (SELECT AVG(Price) FROM Product)
B. SELECT AVG(Price) FROM Product WHERE Price >
C. SELECT * FROM Product HAVING Price > AVG(Price)
D. SELECT * FROM Product GROUP BY AVG(Price)

Q94: Which CASE expression labels a NULL PhoneNumber as 'Unknown'?
A. CASE WHEN PhoneNumber IS NULL THEN 'Unknown' ELSE PhoneNumber END
B. CASE PhoneNumber = NULL THEN 'Unknown'
C. IF PhoneNumber IS NULL 'Unknown'
D. CASE NULL PhoneNumber THEN 'Unknown'

Q95: Which query returns the second highest salary from the Employee table?
A. SELECT MAX(Salary) FROM Employee
B. SELECT TOP 1 Salary FROM Employee ORDER BY Salary DESC
C. SELECT MAX(Salary) FROM Employee WHERE Salary < (SELECT MAX(Salary) FROM Employee)
D. SELECT TOP 2 Salary FROM Employee ORDER BY Salary DESC

Q96: Which SQL Server function returns the last day of the month for a given date?
A. EOMONTH(OrderDate)
B. LASTDAY(OrderDate)
C. MONTHEND(OrderDate)
D. ENDOFMONTH(OrderDate)

Q97: Which query returns employees whose names have exactly five characters?
A. SELECT * FROM Employee WHERE Name LIKE '_____'
B. SELECT * FROM Employee WHERE Name LIKE '%%%%%'
C. SELECT * FROM Employee WHERE LEN(Name)=4
D. SELECT * FROM Employee WHERE Name='_____'

Q98: Which query returns the largest order amount?
A. SELECT MAX(Amount) FROM Orders
B. SELECT TOP(Amount) FROM Orders
C. SELECT HIGH(Amount) FROM Orders
D. SELECT LAST(Amount) FROM Orders

Q99: Which query removes duplicate rows from the result set?
A. SELECT DISTINCT DepartmentID FROM Employee
B. SELECT UNIQUEROW DepartmentID FROM Employee
C. SELECT SINGLE DepartmentID FROM Employee
D. SELECT REMOVE DepartmentID FROM Employee

Q100: Which function returns the sign of a number?
A. SIGN(Value)
B. ABS(Value)
C. ROUND(Value)
D. CEILING(Value)

Q101: Which query returns all products except those whose price is 100?
A. SELECT * FROM Product WHERE Price <> 100
B. SELECT * FROM Product WHERE Price >< 100
C. SELECT * FROM Product WHERE Price NOT 100
D. SELECT * FROM Product WHERE Price != =100

Q102: Which JOIN produces every possible combination of rows from two tables?
A. INNER JOIN
B. CROSS JOIN
C. LEFT JOIN
D. FULL JOIN

Q103: Which query groups records by Year(OrderDate)?
A. SELECT YEAR(OrderDate),COUNT(*) FROM Orders GROUP BY YEAR(OrderDate)
B. SELECT YEAR(OrderDate),COUNT(*) FROM Orders ORDER BY YEAR(OrderDate)
C. SELECT YEAR(OrderDate),COUNT(*) GROUP Orders
D. SELECT COUNT(*) BY YEAR(OrderDate)

Q104: Which query returns the first occurrence of the word 'SQL' replaced by 'Database'?
A. SELECT REPLACE(Title,'SQL','Database')
B. SELECT CHANGE(Title,'SQL','Database')
C. SELECT SWITCH(Title,'SQL','Database')
D. SELECT UPDATE(Title,'SQL','Database')

Q105: Which query assigns row numbers according to Salary descending?
A. SELECT ROW_NUMBER() OVER(ORDER BY Salary DESC) FROM Employee
B. SELECT ROWNUM(Salary DESC) FROM Employee
C. SELECT NUMBERROW() FROM Employee
D. SELECT AUTONUMBER() FROM Employee

Q106: Which query returns the current date without the time portion?
A. SELECT CAST(GETDATE() AS DATE)
B. SELECT GETDATEONLY()
C. SELECT TODAY()
D. SELECT DATE(GETDATE())

Q107: Which query retrieves rows where Email has no value?
A. SELECT * FROM Customer WHERE Email IS NULL
B. SELECT * FROM Customer WHERE Email=''
C. SELECT * FROM Customer WHERE Email=NULL
D. SELECT * FROM Customer WHERE Email LIKE NULL

Q108: Which function returns the remainder after dividing 23 by 5?
A. 23 % 5
B. DIV(23,5)
C. MODULO(23,5)
D. REMAINDER(23,5)

Q109: Which query concatenates FirstName, a space, and LastName?
A. SELECT CONCAT(FirstName,' ',LastName)
B. SELECT MERGE(FirstName,LastName)
C. SELECT APPEND(FirstName,LastName)
D. SELECT COMBINE(FirstName,LastName)

Q110: Which constraint guarantees that every Order belongs to an existing Customer?
A. FOREIGN KEY
B. CHECK
C. DEFAULT
D. UNIQUE

Q111: Which query returns departments with fewer than five employees?
A. SELECT DepartmentID FROM Employee GROUP BY DepartmentID HAVING COUNT(*)<5
B. SELECT DepartmentID FROM Employee WHERE COUNT(*)<5
C. SELECT COUNT(*)<5 FROM Employee
D. SELECT DepartmentID HAVING COUNT(*)<5

Q112: Which function returns the numeric value raised to the third power?
A. POWER(Value,3)
B. EXP(Value,3)
C. SQRT(Value,3)
D. CUBE(Value)

Q113: Which query finds all employees whose names do not begin with 'M'?
A. SELECT * FROM Employee WHERE Name NOT LIKE 'M%'
B. SELECT * FROM Employee WHERE Name <> 'M%'
C. SELECT * FROM Employee WHERE Name != 'M'
D. SELECT * FROM Employee WHERE Name NOT 'M%'

Q114: Which query extracts the day of the month from InvoiceDate?
A. SELECT DAY(InvoiceDate)
B. SELECT DATEPART(MONTH,InvoiceDate)
C. SELECT MONTHDAY(InvoiceDate)
D. SELECT GETDAY(InvoiceDate)

Q115: Which query returns the first non-NULL value between HomePhone and MobilePhone?
A. SELECT COALESCE(HomePhone,MobilePhone)
B. SELECT ISNULL(HomePhone,MobilePhone,NULL)
C. SELECT NULLIF(HomePhone,MobilePhone)
D. SELECT CHOOSE(HomePhone,MobilePhone)

Q116: Which query sorts Salary descending and EmployeeID ascending?
A. ORDER BY Salary DESC, EmployeeID ASC
B. ORDER BY Salary ASC, EmployeeID DESC
C. SORT Salary DESC, EmployeeID ASC
D. ORDER Salary DESC, EmployeeID ASC

Q117: Which CASE expression labels salaries over 10000 as 'Excellent', between 7000 and 10000 as 'Good', otherwise 'Average'?
A. CASE WHEN Salary>10000 THEN 'Excellent' WHEN Salary>=7000 THEN 'Good' ELSE 'Average' END
B. IF Salary>10000 THEN 'Excellent'
C. CASE Salary>10000='Excellent'
D. WHEN Salary>10000 THEN 'Excellent'

Q118: Which query returns the first eight rows after sorting by ProductID?
A. SELECT TOP 8 * FROM Product ORDER BY ProductID
B. SELECT LIMIT 8 * FROM Product ORDER BY ProductID
C. SELECT FIRST 8 * FROM Product ORDER BY ProductID
D. SELECT * TOP 8 Product

Q119: Which query converts the string '2026-12-31' to a DATE value?
A. SELECT CAST('2026-12-31' AS DATE)
B. SELECT DATE('2026-12-31')
C. SELECT TO_DATE('2026-12-31')
D. SELECT PARSEDATE('2026-12-31')

Q120: Which query calculates the average salary rounded to two decimal places?
A. SELECT ROUND(AVG(Salary),2) FROM Employee
B. SELECT AVG(ROUND(Salary)) FROM Employee
C. SELECT ROUND(Salary,2) FROM Employee
D. SELECT AVG2(Salary) FROM Employee

(Ghi chú: Phần câu hỏi Qi có màu Green thể hiện đáp án đúng)

(Ghi chú: Phần câu hỏi Qi có màu Green thể hiện đáp án đúng)
» Tiếp: Bài làm mẫu 1
« Trước: Quiz
Khóa học qua video:
Lập trình Python All Lập trình C# All SQL Server All Lập trình C All Java PHP HTML5-CSS3-JavaScript
Đăng ký Hội viên
Tất cả các video dành cho hội viên
Copied !!!