I have a table with these columns: stockNumber, storageID, lastPutDate, qtyOnHand
Each stockNumber can have multiple storageID's but only one lastPutDate and qtyOnHand for each storageID.
Here is an example of what the rows might look like:
stockNumber storageID lastPutDate qtyOnHand
----------- --------- ----------- ---------
100505 R010101 2012-10-18 150.00
100505 R010102 2012-10-17 75.00
100505 R010103 2012-11-10 97.00
100125 R020101 2012-11-12 200.00
100125 R020204 2012-9-17 500.00
30222 R030101 2012-12-2 63.00
I'm trying to figure out the correct query to end with this result:
stockNumber storageID lastPutDate qtyOnHand
----------- --------- ----------- ---------
100505 R010101 2012-10-18 150.00
R010102 2012-10-17 75.00
R010103 2012-11-10 97.00
100125 R020101 2012-11-12 200.00
R020204 2012-9-17 500.00
30222 R030101 2012-12-2 63.00
So far I've been trying something like this:
SELECT stockNumber, storageID, lastPutDate, qtyOnHand FROM WTStockQtys
GROUP BY stockNumber
That's not working though and I'm not even sure if GROUP BY is the right way to do this.
Can anyone help?