以下是我所拥有的
+++++++++++++++++++++++++++
id + myDate + name
+++++++++++++++++++++++++++
'A'+ '2012-06-05' + 'baz'
'A'+ '2012-06-04' + 'bar'
'B'+ '2012-06-05' + 'foo'
'C'+ '2012-06-05' + 'bla'
'C'+ '2012-06-04' + 'blah'
'C'+ '2012-06-06' + 'bleh'
+++++++++++++++++++++++++++
我正在使用的查询是
SELECT id, min(myDate) as Date, name
FROM myTable
GROUP BY id;
我得到如下输出
+++++++++++++++++++++++++++
id + myDate + name
+++++++++++++++++++++++++++
'A'+ '2012-06-04' + 'baz'
'B'+ '2012-06-05' + 'foo'
'C'+ '2012-06-04' + 'bla'
+++++++++++++++++++++++++++
我的问题是当查询给我正确的日期时,为什么列的数据name
是baz而不是bar因为name
日期2012-06-04
是bar。
演示来测试数据。