Simple newbie question (1 Viewer)

Cabong

New member
Local time
Today, 06:52
Joined
Jul 31, 2005
Messages
7
I have a table with style number field, a style description field, a INSTOCK ("Yes/No") field, and a qty field.

Some of the style numbers are unique, others appears many times in the table.

I want to be able to get a list of all the styles in the same manner I would do using SELECT DISTINCT, meaning one line per style and the sum of the qty for identical style in the table.

Up to that point I have no problem as I use something like:

Select STYLENO, sum(QTY) as SumOfQty, grouped by STYLENO

The catch is, whenever there are many identical styles, I have to return the STYLEDESC only where INSTOCK = "No". There could be one record with a "No" or many of them at any given point. But each styles has at least 1 record with INSTOCK = "No".

If there are many lines with a "No", it doesn't matter which one I pick, as long I pick one where INSTOCK = "No" to get the right description.

I hope I'm explaining this right.

Can anyone help me? I'm sure this ain't too difficult.

TIA
 

FoFa

Registered User.
Local time
Today, 05:52
Joined
Jan 29, 2003
Messages
3,672
If you wish to return that description with your other data, and the descriptions where INSTOCK = Yes are NULL, I would just try MAX([STYLEDESC]) the same way you are using SUM(QTY).
If you mean something....
 

Users who are viewing this thread

Top Bottom