> > select
> > sum(box)
[quoted text clipped - 28 lines]
> IDnum desc)
> ?
ahh the power of parenthesis
box = (SELECT SUM(box) FROM batchdata WHERE IDnum >= (SELECT
(MAX(IDnum)-1) FROM batchdata))
I had to make sure the parenthesis were all in the correct spot.
Especially since I am doing this for 4 columns and there was a comma
at the end
M A Srinivas - 30 Jul 2007 10:13 GMT
> > > select
> > > sum(box)
[quoted text clipped - 39 lines]
>
> - Show quoted text -
You need to make sure the following . (assuming you don't want to sum
duplicate values )
1. There are no duplicate maximum values
2. A row with maximum - 1 exists and this also should not have any
duplicates .
you may be looking for next to maximum ( not max - 1 ) . ie
Your values should not have gaps
8
6
5
3
In this case max = 8 , max - 1 = 7 does not exist