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.
是否可以获取 max(column1) 的 column2 值。帮我。我必须在数据库中找到与 max(price) 和 min(price) 对应的日期。
$str="select MAX(psq_price),MIN(psq_price),AVG(psq_price) from crawl_archives where p_id=2570";
我从这个查询中找到了 max , min 值..需要找到与最高价格对应的日期列..
尝试这样的事情:
select * from <table> t join (select max(price) as max_price from <table> group by <col1> )a on a.col1=t.col1 and a.max_price=t.price
试试这个
select date , MAX(psq_price),MIN(psq_price) from mytable group by date