How do I select the first row per group in an SQL Query?

后端 未结 9 1002
别跟我提以往
别跟我提以往 2020-12-29 09:26

I\'ve got this SQL query:

SELECT   Foo, Bar, SUM(Values) AS Sum
FROM     SomeTable
GROUP BY Foo, Bar
ORDER BY Foo DESC, Sum DESC

This resul

9条回答
  •  情书的邮戳
    2020-12-29 10:16

    Is this an opportunity to use a 'HAVING' clause ? (You want to discriminate on an aggregate function - 'Sum') ?

提交回复
热议问题