SQL query to find unique column values from table
We take a sample table named Geeks and return unique column values by applying various SQL queries on it.
Table – Geeks
| G_ID | FIRSTNAME | LASTNAME | JOININGDATE | DEPARTMENT |
|---|---|---|---|---|
| 1 | Mohan | Arora | 7-08-2019 | DBA |
| 2 | Nisha | Verma | 25-03-2017 | Admin |
| 3 | Vishal | Gupta | 9-01-2020 | DBA |
| 4 | Amita | Singh | 5-12-2017 | Writer |
| 5 | Vishal | Bharti | 3-05-2018 | Admin |
| 6 | Vinod | Diwan | 19-04-2018 | Review |
| 7 | Sheetal | Kumar | 5-01-2017 | Review |
| 8 | Geeta | Chauan | 5-02-2019 | Admin |
| 9 | Mona | Mishra | 15-01-2018 | Writer |
SQL query to find unique values of column department from Geeks table.
Select distinct DEPARTMENT from Geeks;
Output –
| DEPARTMENT |
|---|
| Admin |
| DBA |
| Review |
| Writer |
SQL query to find details of column department where name as “DBA”.
Select * from Geeks where DEPARTMENT like 'DBA%';
Output –
| G_ID | FIRSTNAME | LASTNAME | JOININGDATE | DEPARTMENT |
|---|---|---|---|---|
| 1 | Mohan | Arora | 7-08-2019 | DBA |
| 3 | Vishal | Gupta | 9-01-2020 | DBA |
SQL query to find the count of rows in the department ‘Admin’.
SELECT COUNT(*) FROM Geeks WHERE DEPARTMENT = 'Admin';
Output –
| (No column name) |
|---|
| 3 |







Please Login to comment...