Results 1 to 3 of 3

Thread: SQL conditional IF, help with

  1. #1
    Join Date
    Oct 2002
    Posts
    5

    SQL conditional IF, help with

    Working with MSAccess2000

    SELECT (IIf(paybycheck.anonym=1, "anonym", paybycheck.name)) AS name,
    city,state,amount,checkdate,anonym
    FROM paybycheck
    WHERE fund = '#tpcid#'
    group by name,city,state,amount,anonym,checkdate
    order by name asc
    </CFQUERY>

    returns "-1" instead of the word "anonym" AS name


    I have also tried

    SELECT
    case when paybycheck.anonym=1 then 'anonym' else paybycheck.name end AS name
    FROM paybycheck
    WHERE 1=1

    and this

    SELECT
    CASE paybycheck.anonym
    WHEN 1 then 'anonym'
    WHEN 0 then paybycheck.name
    END as name
    FROM paybycheck
    WHERE 1=1

    and a host of variations, at no avail.
    These last two, keeps generating the "missing operator in query espression" error. (in ColdFusion)

    Any thought?

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    Did you try this

    SELECT 'Name' =
    CASE paybycheck.anonym
    WHEN 1 then 'anonym'
    WHEN 0 then paybycheck.name
    END
    FROM paybycheck
    WHERE 1=1

  3. #3
    Join Date
    Oct 2002
    Posts
    5
    Thanks skhanal.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •