My question is similar to SQL select Group query . But there are changes in the circuit, and I need a different result, as indicated below. the solutions of this link do not give me the correct solutions. You can use SQL script to solve this problem.
Below is my table
Table 1
+--------+----------+---------+ | amount | make | product | +--------+----------+---------+ | 100 | Nokia | Mobiles | | 300 | Samesung | Mobiles | | 700 | Micromax | Mobiles | | 1000 | Karbonn | Mobiles | | 300 | Lava | Mobiles | | 100 | Floyer | Gift | | 500 | Arichies | Gift | | 300 | Feeling | Gift | +--------+----------+---------+
Now I want to display the two lowest amounts for each product, and if the quantity is the same as any according to the ascending order of the column alphabet ...
So, I want to build one SQL query that gives me the result, as shown below.
+--------+----------+---------+ | amount | make | product | +--------+----------+---------+ | 100 | Nokia | Mobiles | | 300 | Lava | Mobiles | | 100 | Floyer | Gift | | 300 | Feeling | Gift | +--------+----------+---------+
Please help me build such a query.
source share