vendredi 24 juin 2016

How to get combinations of items with a condition / Limit?

I'm trying to make a combination list. I have this test table. ID Item Stock Price A1 Apple 20 250 A2 Grape 50 500 A3 Lychee 0 650 A4 Orange 150 550 A5 Date 5 850 Let's say I set a limit of 10000. This means the SELECT query have a condition like this. (WHERE Total > 0 AND Total <= 10000) The result example (ignore the spacing): Combination Item Purchase Total T001 Apple 10 2500 //This is APPROVED because the total is under 10000 T002 Apple 5 1250 //This T002 has two items. The Total of T002 is 6250 T002 Grape 10 5000 //So, It is APPROVED T003 Lychee 50000 32500000 //Because the Stock of Lychee is 0, This is REJECTED T004 Date 10 8500 //Because the Purchase > Stock (10 > 5), This is REJECTED T005 Orange 5 2750 //This T005 has two items. T005 Date 1 850 //The Total of T005 is 16100. T005 Apple 50 12500 //So, It is REJECTED nb: The Limit (in this example is 10000) is set by user. The Purchase is any integer > 0. (or should I limit it to 10000 > Purchase > 0 )? The REJECTED item is SHOULD NOT shown in the list. Is it possible to make the list from MySQL query only? Any help and suggestions are greatly appreciated. Thank You so much.

Aucun commentaire:

Enregistrer un commentaire