[英]Select many columns based on lowest value from multiple columns (ms access)
I searched through google but all in vain, might be due to my search query. 我通过谷歌搜索,但全部徒劳,可能是由于我的搜索查询。
I have a table like given below 我有下面的表格
------------------------------------------------------------
| LocalID | ASIN | Price | Shipping | Total | Currancy |
------------------------------------------------------------
| 1 |B01MSMCN13 | 95.99 | 3 | 98.99 | GBP |
------------------------------------------------------------
| 2 |B01MSMCN13 | 100 | 0 | 100.0 | GBP |
------------------------------------------------------------
| 3 |B01MSMCN13 | 104.71| 9.61 | 114.32| GBP |
------------------------------------------------------------
| 4 |B01MSMCN13 | 124.81| 8.95 | 133.76| GBP |
------------------------------------------------------------
| 5 |B073WDMZVT | 139.99| 0 | 139.99| GBP |
------------------------------------------------------------
| 6 |B073WDMZVT | 159 | 0 | 159.0 | GBP |
------------------------------------------------------------
| 7 |B073WDMZVT | 179 | 0 | 179 | GBP |
------------------------------------------------------------
Problem: 问题:
I want to take all columns based on the lowest price + shipping 我想根据最低价格+运费来获取所有列
The Result I want like this 我想要这样的结果
------------------------------------------------------------
| LocalID | ASIN | Price | Shipping | Total | Currancy |
------------------------------------------------------------
| 1 |B01MSMCN13 | 95.99 | 3 | 98.99 | GBP |
------------------------------------------------------------
| 5 |B073WDMZVT | 139.99| 0 | 139.99| GBP |
------------------------------------------------------------
I have tried many queries but couldn't get the desired results. 我已经尝试了许多查询,但无法获得理想的结果。
Your help will be highly appreciated. 非常感谢您的帮助。
Use min func and group by 使用min func并分组
SELECT *
FROM Table t
WHERE Total = (SELECT MIN(Total)
FROM Table t2
WHERE t.ASIN = t2.ASIN
GROUP BY ASIN)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.