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

Can this be done with an SQL-query?

Status
Not open for further replies.

tar

Programmer
Aug 3, 1999
1
SE
I have a table that looks approximately like this:<br>
ArtNbr ArtType Revision NbrManufactured<br>
1-1 type 1 0 52<br>
1-2 type 1 1 123<br>
1-3 type 1 2 32<br>
2-1 type 2 0 121<br>
2-2 type 2 1 42<br>
2-3 type 2 2 21<br>
2-4 type 2 3 11<br>
. . . .<br>
. . . .<br>
<br>
What I want to do is to sum the nbr of manufactured units<br>
for each article type, and also get the ArtNbr of the last revision.<br>
<br>
For the example above that would be:<br>
1-3 (doesn't matter)(doesn't matter) 207<br>
2-4 (doesn't matter)(doesn't matter) 195<br>
<br>
I'm having trouble getting the last ArtNbr to "tuple up" with the sums. Can this be done with an SQL-query?<br>
<br>
Grateful for _any_ tips,<br>
tar<br>

 
Write two queries; one to get the sum and one to get the ArtNbr of the max date.<br>
<br>
Then, write another query that joins the first two queries on the key fields.<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top