471,090 Members | 1,371 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,090 software developers and data experts.

Pick until enough

[Note] this question is cross-posted to 3 unrelated ngs. Please followup
only to 1.

Hi,

How can I do this:
select g_name from goods order by g_priority where sum(g_value) < 500

I.e., I want to orderly pick from table goods so that the total picked
value is less than a defined value.

Certainly the above sql won't work (tested under mysql). How can I do it?
Thanks!

--
Tong (remove underscore(s) to reply)
*niX Power Tools Project: http://xpt.sourceforge.net/
- All free contribution & collection
Jul 23 '05 #1
1 1149
* Tong * wrote:
[Note] this question is cross-posted to 3 unrelated ngs. Please followup
only to 1.

Hi,

How can I do this:
select g_name from goods order by g_priority where sum(g_value) < 500

I.e., I want to orderly pick from table goods so that the total picked
value is less than a defined value.

Certainly the above sql won't work (tested under mysql). How can I do it?
Thanks!

select g_name from
(select sum(g_value) over(order by g_priority) as running_sum,
g_name from goods) as g where running_sum < 500

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by * Tong * | last post: by
4 posts views Thread by Jerry Camel | last post: by
5 posts views Thread by Stuart McDougall | last post: by
7 posts views Thread by Thomas Nelson | last post: by
reply views Thread by =?Utf-8?B?TmVpbGUgQmVybXVkZXM=?= | last post: by
13 posts views Thread by Martin Sand Christensen | last post: by
36 posts views Thread by Krustov | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.