Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie to SQL question

Status
Not open for further replies.

Dnisss

Technical User
Oct 6, 2005
1
CA
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.

Does anyone care to give it a shot?

TIA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top