我有一个简单的 MySQL 选择语句:
SELECT COUNT(*) AS COUNT FROM MY_TABLE WHERE TIME_STAMP > ?
但是,如果最早行的 TIME_STAMP 大于我的 WHERE 阈值,我不想计算第一行/最早行。就像是:
SELECT COUNT(*) AS COUNT FROM MY_TABLE WHERE TIME_STAMP > ? AND TIME_STAMP > $earliest
显然,我可以通过额外的先前查询获得最早的 TIME_STAMP。但我在徘徊,如果我能做到这一切。我试过了,但抛出了“无效使用组函数”错误:
SELECT COUNT(*) AS COUNT FROM MY_TABLE WHERE TIME_STAMP > ? AND TIME_STAMP > MIN(TIME_STAMP)
有什么建议么?谢谢