Question: I had tried using the the below query but couldn't retrive the distinct values of the column `status_id`. 

```
select distinct status_id, schedule_id, cassay_id, time_of_day,
                days, notify_to_addresses, active FROM ordertest

```

The purpose of the the above query is to filter the table to get the unique value of the column '`status_id`' at the same time it needs to fetch values for all columns present in the table. So that my final table will consist of the distinct values of `status_id` and their corresponding other values.

Answer: 
```
WITH DISTINCT_STATUS
AS
(
-- this one will query distinct status id values
   select DISTINCT status_id FROM ordertest
)
-- this query will give extra information in that rows.
select distinct T.status_id, T.schedule_id, T.cassay_id, T.time_of_day,
            T.days, T.notify_to_addresses, T.active 
FROM ordertest T 
INNER JOIN 
DISTINCT_STATUS DS
ON DS.status_id = T.status_id

```
`DISTINCT` works for each row, other fields are not same for all distinct `status_id`, so you can not use DISTINCT.

Use `GROUP BY`, and use Group functions (`MAX,MIN,WM_CONCAT` **WHAT YOU NEED**) for other Columns.

OR use `subqueries` by `primary key` for each column.