I have a table with rows/data in the following structure
-----------
| SURVEY_ID |
------------
| 1 |
| 2 |
| 2 |
| 3 |
| 4 |
-----------
I want to get the distinct IDs and the maximum id in the same query. I tried
select distinct(survey_id) as survey_id , max(survey_id) as current
from survey_main
group by survey_id
This doesn't seem to return the correct result. What am I missing?
Edit: Required result
---------------------- | Distinct| Max | ---------------------- | 1 | 4 | | 2 | 4 | | 3 | 4 | | 4 | 4 | ----------------------