Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Which of the following queries on table STUDENT will return number 2 as a result

ID: 3707141 • Letter: W

Question

Which of the following queries on table STUDENT will return number 2 as a result?

STUDENT

Observe the table STUDENT:

STUDENT

StudentID        SSN                  Name           Class

D111              111-11-1111         Connor       Freshman

D222              222-22-2222         Trevor         Freshman

D333              333-33-3333         Connor       Sophomore

D444              444-44-4444         Parker         Sophomore

D555              555-55-5555         Connor       Sophomore

Select one:

a. SELECT COUNT(name) FROM student;

b. SELECT COUNT(class) FROM student;

c. SELECT COUNT(DISTINCT class) FROM student;

d. SELECT COUNT(*) FROM student;

Explanation / Answer

Answer : (c) SELECT COUNT(DISTINCT class) FROM student;

DISTINCT returns the set of distinct elements.

In the class column, there are only 2 distinct elements:

So, the count() return the count of the data set passed as argument which is of size 2. SO, 2 is printed.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote