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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with a SQL Statement

Status
Not open for further replies.

demoman

Programmer
Oct 24, 2001
242
US
Sorry folks, but I left my bigger brain at home today. Need help with the following problem. I need to write a SQL Statement that produces the results below.

Actual data:

PART LOOCATION QTY NEED BALANCE
Wrench 125-A 11 3 8
Wrench 125-A 11 2 9

Needs to look like (single line for a VB datagrid):

PART LOOCATION QTY NEED BALANCE
Wrench 125-A 11 5 6

Note: Balance is computed, not actual data. Appreciate the help as always!

-Steve-
 
Is this data in a single table or multiple tables?

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
This?
Code:
select part, loocation, qty, sum(need), qty-sum(need)
from myTable
group by part, loocation, qty

------
heisenbug: A bug that disappears or alters its behavior when one attempts to probe or isolate it
schroedinbug: A bug that doesn't appear until someone reads source code and realizes it never should have worked, at which point the program promptly stops working for everybody until fixed.
 
It is from a view, so it would behave as a single table statement
 
That is what I meant by 'the bigger brain'. I had (need) in the group by. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top