简体   繁体   中英

error code : 1241 Operand should contain 1 column(s) 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;

Giving error Operand should contain 1 column(s)

Trying to fetch the appropriate loginid , company name , fa_name by grouping the lot and get max purchaseprice.

Please help. Thanks in advance

Your subselect can only have one value in select clause:

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM