|
Posted by Hugo Kornelis on 06/07/06 08:42
On 6 Jun 2006 17:45:58 -0700, Alexander Kuznetsov wrote:
>one more question: what if there is only one row with negative amount?
>
>INSERT INTO t1 VALUES (11, '20060101', '2321323', -100.00)
>
>and there is no corresponding row with positive amount? Nothing in the
>posted DDL prevents you from that. In fact, originally I was
>considering the query posted by Hugo, but realized it would return that
>single row with negative amount and assumed it incorrect. It looks like
>there might be no base for my assumption.
Hi Alexander,
I've seenn nothing in the original post that justifies special treatment
of negative amounts. If these should be excluded, then my version can
still be used - just add AND MAX(TaxableAmount) >= 0 to the HAVING
clause.
However, I agree with Erland that a redesign might be a better choice if
something like that is the case.
--
Hugo Kornelis, SQL Server MVP
[Back to original message]
|