SQL query summation

后端 未结 2 1201
再見小時候
再見小時候 2021-01-29 07:44

I have two tables

Unit

Unit_id
Unit_name
Unit_cost

Components

Component_id
Component_         


        
2条回答
  •  半阙折子戏
    2021-01-29 08:31

    I think you want something like this:

    select top (1) u.unit_name
    from unit u join
         component c
         on c.unit_id = u.unit_id
    group by u.unit_id, u.unit_name
    order by sum(c.cost) desc;
    

提交回复
热议问题