150k views
5 votes
In an SQL query, which SQL keyword must be used to remove duplicate rows from the result table?

a) DELETE
b) DISTINCT
c) NOT EXISTS
d) UNIQUE
e) KEY

User Miszczu
by
7.5k points

1 Answer

3 votes

Final answer:

In an SQL query, to remove duplicate rows from the result table, the DISTINCT keyword is used. It filters out duplicates, ensuring that each row in the results is unique.

Step-by-step explanation:

To remove duplicate rows from the result table in an SQL query, the SQL keyword DISTINCT should be used. When you add the DISTINCT keyword to a SELECT statement, the database system will ensure that only unique rows are returned, effectively filtering out any duplicates that might exist in the result set.

For example, if you're querying a database of students and want to know all the different grades that students have obtained without any duplicates, you would use the following SQL query:

Select DISTINCT grade from students;

This would return each grade present in the students table just once, even if multiple students have received the same grade.

User Ben Trewern
by
7.3k points