select * from 表 aa where 采购单价=(select max(采购单价) from 表 where and 进货数量=(select max(进货数量) from 表)) ??
select * from table where 进货数量=(select max(进货数量) from table) and 采购单价=(select max(采购单价) from table)orselect * from table A, (select max(进货数量) 进货数量,max(采购单价) 采购单价 from table) B where a.进货数量=b.进货数量 and a.采购单价=b.采购单价
select * from table where 进货数量=(select max(进货数量) from table) and 采购单价=(select max(采购单价) from table)orselect A.* from table A, (select max(进货数量) 进货数量,max(采购单价) 采购单价 from table) B where a.进货数量=b.进货数量 and a.采购单价=b.采购单价
你能保证进货数量最大时采购单价也是最大么?select * from table where 进货数量 =(select max(a.进货数量) from table1 a where a.客户=table.客户) 如果是这样 a b a 3 4 a 3 40 a 40 80 a 80 10 a 80 90 a 70 100a最大b不为最大 就不符合条件了
如果是上面的情况 那么用 select * from table where 进货数量=(select max(进货数量) from table) and 采购单价=(select max(采购单价) from table) 将查不出任何结果,因为不是同一条记录
谢谢大家的解答,我已写出语法了 select * from 门禁纪录 where 进出时间=( select max(进出时间) As 进出时间 from 门禁纪录 where 进出日期=(select max(进出日期) As 进出日期 from 门禁纪录)
select * from 表名 where 采购单价=(select max(采购单价) from 表 where and 进货数量=(select max(进货数量) from 表))
??
and 采购单价=(select max(采购单价) from table)orselect *
from table A,
(select max(进货数量) 进货数量,max(采购单价) 采购单价 from table) B
where a.进货数量=b.进货数量 and a.采购单价=b.采购单价
and 采购单价=(select max(采购单价) from table)orselect A.*
from table A,
(select max(进货数量) 进货数量,max(采购单价) 采购单价 from table) B
where a.进货数量=b.进货数量 and a.采购单价=b.采购单价
进货数量 =(select max(a.进货数量) from table1 a where a.客户=table.客户)
如果是这样
a b
a 3 4
a 3 40
a 40 80
a 80 10
a 80 90
a 70 100a最大b不为最大 就不符合条件了
那么用
select * from table where 进货数量=(select max(进货数量) from table)
and 采购单价=(select max(采购单价) from table)
将查不出任何结果,因为不是同一条记录
select * from 门禁纪录
where 进出时间=(
select max(进出时间) As 进出时间
from 门禁纪录
where 进出日期=(select max(进出日期) As 进出日期 from 门禁纪录)
from 表 where and 进货数量=(select max(进货数量) from 表))