Php 获取column1最大值和最小值对应的column2值?
是否可以获取maxcolumn1的column2值。帮助我。我在数据库中找到了maxprice和minprice对应的日期Php 获取column1最大值和最小值对应的column2值?,php,mysql,Php,Mysql,是否可以获取maxcolumn1的column2值。帮助我。我在数据库中找到了maxprice和minprice对应的日期 $str="select MAX(psq_price),MIN(psq_price),AVG(psq_price) from crawl_archives where p_id=2570"; 我在此查询中找到了最大值、最小值。。需要找到与最高价格对应的日期列。请尝试以下操作: select * from <table> t join (select max(
$str="select MAX(psq_price),MIN(psq_price),AVG(psq_price) from crawl_archives where p_id=2570";
我在此查询中找到了最大值、最小值。。需要找到与最高价格对应的日期列。请尝试以下操作:
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
1.你试过的2。给出你的代码3。提供更多细节4。得到好的帮助。你在使用php标签吗?php在哪里?