在同一查询中选择 DISTINCT 和 MAX

Vai*_*esh 2 sql

我有一个包含以下结构的行/数据的表

-----------
| SURVEY_ID |
------------
|  1       |
|  2       |
|  2       |
|  3       |
|  4       |
-----------
Run Code Online (Sandbox Code Playgroud)

我想在同一查询中获取不同的 ID 和最大 ID。我试过

select distinct(survey_id) as survey_id , max(survey_id) as current 
from survey_main 
group by survey_id
Run Code Online (Sandbox Code Playgroud)

这似乎没有返回正确的结果。我缺少什么?

编辑:所需结果

        ----------------------
        | 与众不同| 最大|
        ----------------------
        | 1 | 4 |
        | 2 | 4 |
        | 3 | 4 |
        | 4 | 4 |
        ----------------------

Tri*_*mon 9

我认为Itay Moav-Malimovka的解决方案非常完美,但是如果您真的想要有两列,您可以使用......

select distinct(survey_id) as identifier, 
       (select max(survey_id) from survey) as "current" 
  from survey_main;
Run Code Online (Sandbox Code Playgroud)

干杯!