当前位置: 动力学知识库 > 问答 > 编程问答 >

mysql - GROUP BY, show MIN

问题描述:

I have the following query to get me a list of titles:

select

title,

date

from

financials,

order by

title, date

title date

1,000 Times More Brutal 2013-06-01

1,000 Times More Brutal 2013-07-01

1,000 Times More Brutal 2013-07-01

1,000 Times More Brutal 2013-07-01

1,000 Times More Brutal 2013-08-01

1,000 Times More Brutal 2013-09-01

1,000 Times More Brutal 2013-09-01

1,000 Times More Brutal 2013-09-01

1,000 Times More Brutal 2013-09-01

1,000 Times More Brutal 2013-10-01

1,000 Times More Brutal 2013-10-01

1,000 Times More Brutal 2013-10-01

11'e 10 Kala 2012-12-01

11'e 10 Kala 2012-12-01

11'e 10 Kala 2012-12-01

11'e 10 Kala 2012-12-01

11'e 10 Kala 2013-01-01

I need to group the titles and then get the MIN(date) of the transaction. The correct query would yield:

title date

1,000 Times More Brutal 2013-06-01

11'e 10 Kala 2012-12-01

How would I use a GROUP BY query to get the min date here?

网友答案:
SELECT title, MIN(date)
FROM financials
GROUP BY title
ORDER BY title
网友答案:
select title, min(date)
from financials
group by title
order by title, date
网友答案:
SELECT title, MIN(date) 
FROM financials
GROUP BY title
网友答案:
select title, min(date) from financials group by title order by title
分享给朋友:
您可能感兴趣的文章:
随机阅读: