T-SQL: Selecting Column Based on MAX(Other Column)

后端 未结 7 698
醉酒成梦
醉酒成梦 2020-11-27 12:06

I\'m hoping there\'s a simple way to do this without using a sub-query:

Scenario: You have \"TableA\" with columns \"Key\", \"SubKey\", and \"Value\". I need to ge

7条回答
  •  温柔的废话
    2020-11-27 12:32

    If you'll always want just one row for one key value rather than the answer for many keys at once, all the join stuff is useless overbuilding. Just use the TOP 1 query OMG Ponies already gave you.

提交回复
热议问题