This question is based on the following SQL table MYSTUDENT: ROLLNO NAME SEC…
2022
This question is based on the following SQL table MYSTUDENT:
ROLLNO NAME SEC MARKS
80105 MARIA A 83.0
80108 AMAR B 44.0
80109 MANPREET A 92.0
80112 SAMEER A 81.0
80115 AKBAR B NULL
Which SQL command can be used to display each distinct SEC value from MYSTUDENT?
- A.
SELECT DISTINCT SEC FROM MYSTUDENT;
- B.
SELECT DIFFERENT SEC FROM MYSTUDENT;
- C.
SELECT ALL SEC FROM MYSTUDENT;
- D.
SELECT UNIQUE SEC FROM MYSTUDENT;
Attempted by 1908 students.
Show answer & explanation
Correct answer: A
The query needs to display each SEC value only once.
In SQL, DISTINCT is used with SELECT to remove duplicate values from the result.
The SEC column contains repeated values A and B. Therefore:
SELECT DISTINCT SEC FROM MYSTUDENT;
will return the unique section values A and B. Hence, Option A is correct.
A video solution is available for this question — log in and enroll to watch it.