Thanks guys. Figured it out. Sometimes great to come back in the morning.

where a.ittranstat <> ' '
// select 1 company or all
and (case when :kcompany = 0 then 1
when :kcompany > 0
and :kcompany = a.itcompany then 1
else 0 end) = 1
// select 1 location or all
and (case when :klocate = ' ' then 1
when :klocate > ' '
and :klocate = c.dptloc then 1
else 0 end) = 1


On Tue, Jan 29, 2013 at 8:28 AM, Horn, Jim <jim.horn@xxxxxxxxxxxxxx> wrote:



I know I could do this with dynamic sql but how about static -

I want to put options in the select criteria based on something entered
into the program. Is there some kind of case statement that would work?
Something like -
WHERE
(CASE WHEN 0 = :@COMPANY THEN 1
WHEN 0 < :@COMPANY AND A.ITCOMPANY = @COMPANY THEN 1
ELSE 0
END) = 1

where @company is 0 or a company# entered into the program

Jim


***********************************************************************
The information transmitted is intended solely for the individual or
entity to which it is addressed and may contain confidential and/or
privileged material. Any review, retransmission, dissemination or
other use of or taking action in reliance upon this information by
persons or entities other than the intended recipient is prohibited.
If you have received this email in error please contact the sender and
delete the material from any computer. As a recipient of this email,
you are responsible for screening its contents and the contents of any
attachments for the presence of viruses. No liability is accepted for
any damages caused by any virus transmitted by this email.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.