滥用>聚合:MIN()

时间:2018-01-31 16:20:22

标签: android sqlite

basket:
id: integer primary key
key: integer

product:
id: integer primary key
basket: foreign key Basket.id
price: integer
  

引起:android.database.sqlite.SQLiteException:误用   aggregate:MIN()(Sqlite代码1):,编译时:

SELECT `basket`.* FROM `basket` LEFT JOIN `product` ON `basket`.`id` =  `product`.`basket` WHERE `basket`.`key` = 11 GROUP BY `basket`.`id` ORDER BY MIN(price) DESC LIMIT 100 OFFSET 20 (OS error - 2:No such file or directory)

Android版。 7.0。它适用于Android 4/5/6。它不适用于Android 7.0。有什么问题?

1 个答案:

答案 0 :(得分:0)

我不是因为你可以按顺序使用聚合函数。试试:

SELECT basket.*, MIN(price) As minPrice
  FROM basket
  LEFT JOIN product
    ON basket . id = product . basket
 WHERE basket . key = 11
 GROUP BY basket . id
 ORDER BY minPrice  DESC LIMIT 100 OFFSET 20