My database contents
ID | CLASS_CODE | ROLL_NO | NAME |
---|---|---|---|
1 | IX | 1 | Jijo K Jose |
2 | IX | 3 | James Jacob |
3 | X | 1 | Joy Mathew |
4 | X | 2 | Sam George |
5 | IX | 2 | Miller John |
6 | X | 3 | Thomas John |
Display values of distinct rows over one column
select distinct(ROLL_NO) from STUDENT;
ROLL_NO | |
---|---|
1 | |
3 | |
2 |
Count number of distinct rows over one column
select count(distinct(ROLL_NO)) from STUDENT;
count(distinct(ROLL_NO)) | |
---|---|
3 |
Display values of distinct rows over multiple column
select distinct CLASS_CODE, ROLL_NO from STUDENT;
CLASS_CODE | ROLL_NO | |
---|---|---|
IX | 1 | |
IX | 3 | |
X | 1 | |
X | 2 | |
IX | 2 | |
X | 3 |
Count number of distinct rows over multiple column
select count(*) from (select distinct CLASS_CODE, ROLL_NO from STUDENT) TEMP;
count(*) | |
---|---|
6 |