123FakeSt
IS-IT--Management
- Aug 4, 2003
- 182
I have this in a stored procedure. With the comments, I get a balance of -59.56. When I remove the comments, the toal becomes 0.00.
One of the rows (hppty=9) only appears when select the hppty field, it doesn't add up in the sum otherwise.
Any ideas?
The early bird gets the worm, but the second mouse gets the cheese.
One of the rows (hppty=9) only appears when select the hppty field, it doesn't add up in the sum otherwise.
Any ideas?
Code:
SELECT
SUM(sBegin) + SUM(sMTD) BeginingAmt--, hppty
FROM
TOTAL (NOLOCK)
WHERE
hacct = 1984
AND iBook = 1
AND uMonth BETWEEN convert(datetime,'04/01/2006',101) AND convert(datetime,'05/01/2006',101)
AND hPpty IN
(SELECT
COALESCE(l5.hproperty,l4.hproperty,l3.hproperty,l2.hproperty,l1.hproperty)
FROM
(listprop l1
LEFT JOIN listprop l2 ON l1.hproperty = l2.hproplist
LEFT JOIN listprop l3 ON l2.hproperty = l3.hproplist
LEFT JOIN listprop l4 ON l3.hproperty = l4.hproplist
LEFT JOIN listprop l5 ON l4.hproperty = l5.hproplist)
INNER JOIN property p ON p.hmy = COALESCE(l5.hproperty,l4.hproperty,l3.hproperty,l2.hproperty,l1.hproperty)
WHERE
l1.hproplist = 458
AND p.ITYPE = 3)
--GROUP BY hppty
--ORDER BY hppty
The early bird gets the worm, but the second mouse gets the cheese.