I have 5 columns in sql table and I need all the 5 columns as out put but with distinct operation on three columns
Need to return all the columns with distinct operation on three column
How to achive this?
Timestamp Name State Context
2013-06-24 11:51:03.2550000 tst1 Started E1
2013-06-24 11:56:03.2550000 tst1 Completed E1
2013-06-24 11:51:03.2550000 tst1 Started E1
2013-06-24 11:56:03.2550000 tst1 Completed E1
2013-06-24 11:45:03.2550000 tst1 Started E1
2013-06-24 11:50:03.2550000 tst1 Completed E1
2013-06-24 11:45:03.2550000 tst1 Started E1
2013-06-24 11:50:03.2550000 tst1 Completed E1
Here I am getting all the distinct result for above table by applying distinct on three columns using below query. But I need the distinct of these three columns also need to select context column without applying distict on Context column
SELECT DISTINCT Timestamp,Name,State FROM TableName group by Timestamp,Name,State
Rephrasing my question :
I need to select unique columns from above table . Here only unquie column selection considered as Timestamp,Name,State
Timestamp Name State Context
2013-06-24 11:51:03.2550000 tst1 Started E1
2013-06-24 11:56:03.2550000 tst1 Completed E1
2013-06-24 11:45:03.2550000 tst1 Started E1
2013-06-24 11:50:03.2550000 tst1 Completed E1