-----Original Message-----
From: Peter Willadt [mailto:Willadt@stripped]
Sent: Sunday, April 06, 2003 10:31 AM
To: Brian Kavanaugh; sapdb.general@stripped
Subject: Re: Union in dbproc
> Please excuse me when I'm wrong and also please excuse when my remark is
no
> direct solution to your question, but to me it appears as if the two
queries
> that form the union are identical with the exception of the WHERE clause.
> So you could probably build just one query and combine the two conditions
with
> an OR in the where part. I guess it would also run faster than before.
> So, the where part should look like this:
>
> WHERE
> tblCalendar.isApproved = true AND
> ((DATE <= tblCalendarDtl.EventDate AND
> DATEDIFF( DATE, tblCalendarDtl.EventDate ) < 7
> )
> OR
> (UPPER( tblEventType.EventType ) = 'DEADLINE' AND
> DATE <= tblCalendarDtl.EventDate AND
> DATEDIFF( DATE, tblCalendarDtl.EventDate ) < 30
> ))
>
> Peter Willadt
Is that correct in SAP DB? In MS SQL Server I know that unions are much
faster than using an OR in the WHERE clause... That is the reason I did it
that way, though of course the OR is easier to read, in my opinion...