Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
SELECT min(date(`tx_date`)))) as start_date, `account_id` as 'id' FROM my_table group by id
这是返回每个tx_date而不是分组,并给我每个用户的最小值。我也试过这个start_date:from_days(min(to_days(date(tx_date))))
tx_date
start_date
from_days(min(to_days(date(tx_date))))
我认为您查询中的逻辑很好。您的表是否my_table有一个id作为主键的列?问题可能是查询是按表的id列而不是id您在查询中使用的别名进行分组的。
my_table
id
account_id如果您想在以下位置进行 GROUP,请尝试此操作:
account_id
SELECT min(date(`tx_date`)) as start_date, `account_id` as 'id' FROM my_table group by `account_id`;
我认为您的查询在 min(date( tx_date)) 周围有 2 个额外的右括号,应该会导致错误。