错误代码:1241操作数应包含1列mysql

时间:2015-01-17 07:17:19

标签: mysql

SELECT t1.loginid,t1.`company_name`,t1.`FA_Name`,t1.`Lot`,t1.`PurchasePrice` FROM test_report t1
WHERE PurchasePrice IN (SELECT t1.loginid,t1.`company_name`,t1.`FA_Name`,t1.`Lot`,MAX(t1.`PurchasePrice`) FROM test_report t1 GROUP BY lot)
ORDER BY lot;

给出错误操作数应包含1列

尝试通过对该批次进行分组并获得最大购买价格来获取相应的loginid,公司名称,fa_name。

请帮忙。提前致谢

1 个答案:

答案 0 :(得分:0)

您的子选择在select子句中只能有一个值:

SELECT t1.loginid,t1.`company_name`,t1.`FA_Name`,t1.`Lot`,t1.`PurchasePrice` FROM test_report t1
WHERE PurchasePrice IN (SELECT MAX(t1.`PurchasePrice`) FROM test_report t1 GROUP BY lot)
ORDER BY lot;