如何使用order by和group by together / coalesce and distinct together?

时间:2018-03-22 13:15:16

标签: sql sql-order-by coalesce

我收到了像这样的查询

 select  tm.id as id,
    mf.function_name as function_role,
  e.name as NAME
  from employee e 
  join team_members tm on e.emp_id=tm.emp_id
  join mem_function mf on mf.function_id = tm.function_id
  order by mf.position

对于特定ID,结果集为

 ID | Function_Role | Name
  1    manager        Apple
  1    Engineer       Apple
  1    Engineer 2     Orange

现在我希望我的结果是

   1    Manager       Apple
   1    Engineer2     Orange

有没有办法在不使用select中的select?

的情况下获得此功能

我尝试使用groupby它会抛出错误说"不是按表达式排序" 我也试过select distinct它会抛出错误"不是SELECTed表达式"

注意:我需要按顺序排序和显示

0 个答案:

没有答案