SELECT min(date(`tx_date`)))) as start_date,
`account_id` as 'id'
FROM my_table
group by id
This is returning each tx_date
and not grouping and giving me the min for each user. I've tried this for st开发者_如何学JAVAart_date
as well: from_days(min(to_days(date(tx_date))))
I think the logic in your query is fine. Does you table my_table
has an id
column that is a primary key? The problem might be that the query is grouping by the id
column of your table rather than id
alias that you have used in your query.
Try this if its account_id
you want to GROUP on:
SELECT min(date(`tx_date`)) as start_date, `account_id` as 'id'
FROM my_table
group by `account_id`;
I think your query has 2 extra closing braces around min(date(tx_date
)) and should be causing errors.
精彩评论