DISTINCT Statement

The DISTINCT keyword can be used to return only distinct (different) values. 

Example :- In a table, a column may contain many duplicate values; and sometimes you only want to list the different (distinct) values.

Syntax :- 

  
SELECT DISTINCT column_name,column_name FROM table_name



Example :-We have following table named is tblStudentRecord and it has five columns Name, Rollno, Branch, Email and Address, as shown in below:- 



But, we want to select only two columns Name and Address from tblStudentRecordtable. This type of output get by DISTINCT statement as shown in below. 

  
SELECT DISTINCT Name,Address from tblStudentRecord 



No comments:

Post a Comment

How to register multiple implementations of the same interface in Asp.Net Core?

 Problem: I have services that are derived from the same interface. public interface IService { } public class ServiceA : IService { ...