473,395 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 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
Nov 12 '05 #1
2 1134
Ian
* 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.


In DB2 using the OLAP functions,

select
a.gname
from (
select
gname,
sum(g_value) over (order by g_priority) as running_total
from
goods
) as a
where
a.running_total < 500

Nov 12 '05 #2
* 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
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Gary Mayor | last post by:
Hi, If I have the ' character within the javascript:pick command it doesn't work. Is there some sort of way of escaping these characters like in server side languages. function pick(symbol) {...
1
by: * Tong * | last post by:
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...
4
by: Jerry Camel | last post by:
I'm using a DHTML dialog to present a pick-list to a user. I've got the dialog working using some client side vbscript with a call to window.ShowModalDialog. I can see that the result is being...
10
by: Mark Winter | last post by:
Hello, I am wondering if someone could point me in the right direction to figure out how to create a dynamic form. I have been developing programs in perl and oracle and have recently switched...
5
by: Stuart McDougall | last post by:
Hi, I'm new and naive at JS, but use a lot of modified JS snippets in web design. I'm working on a six-language site for a client right now that has a small nav bar at the bottom of each...
6
by: Ole | last post by:
Hi, I'm running a command line process from my C# application trying to catch the output messages from the process into a textbox in my windows form. But the text doesn't update (the ReadLine...
7
by: Thomas Nelson | last post by:
Occasionally someone posts to this group complaining about the lack of "repeat ... until" in python. I too have occasionally wished for such a construct, and after some thinking, I came up with...
0
by: =?Utf-8?B?TmVpbGUgQmVybXVkZXM=?= | last post by:
Hi there...i don't know if this is more an IIS thing or a .net thing, but i'm trying to figure out why it is sometimes required for the IISAdmin service to be restarted in order for changes to the...
13
by: Martin Sand Christensen | last post by:
Hi! First a bit of context. Yesterday I spent a lot of time debugging the following method in a rather slim database abstraction layer we've developed: ,---- | def selectColumn(self,...
36
by: Krustov | last post by:
What is wrong with this php code ? . (it works fine - but something that just works isnt good enough for this newsgroup is it) <?php $loopy=1; $kon="repo"; $spock=0;
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.