How to question the data base on certain criteria

  • Thread starter Thread starter John Smith
  • Start date Start date
J

John Smith

Hi everyone!

I'm unable to complete my querry.

For exemple, I have blocks that I'm selling. Certains blocks have different
quality and weight.

#Bloc Quality Weight
100 1 23
101 1 12.4
102 2 17.6
103 1 15
104 1 18.4
105 2 21.4
106 2 10.5
107 3 24
108 2 19.4
109 1 16.4
110 2 15.1


I want to be able to question the database to give the list of bloc that
(Quality = 1) and I need 50 weight of blocs. How don't know how to make it
calculate the weight to get approximatly 50 of weight.

The correct list would be Bloc #100,101,103 (Weight = 50.4)

I hope I was clear enough

Thanks

John!
 
Selecting the Quality is easy, just use a query with filter set to
Quality=1.

Getting a set of weights to sum to a specific number ( nearly ! ) is an
extraordinarily difficult problem. The brute force method is to sum all
possible combinations, and select the nearest to your target. You can see
why that is a bad idea !

Would love to see if there are any smart SQL writers around who can find a
reasonable way of doing this.

--
Regards,

Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
 
Back
Top