Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2009
    Posts
    1

    Unanswered: Convert Access IIF Statement to SQL

    Hi Guys,

    I have an access query which calculates the total number of records which have one of three values. So, a total number of records where leadSource is 'Web', another sum where the leadSource is 'Visit' and an third sum where the value is 'Phone':

    SELECT sf_entries.entryID, sf_entries.entryName, Sum(IIf([leadSource] = "Web",1,0)) AS Website,
    Sum(IIf([leadSource] = "Visit",1,0)) AS Visitors, Sum(IIf([leadSource] = "Phone",1,0)) AS Phone, COUNT(*) AS Total
    FROM sf_leads, sf_entries

    I need to migrate this to SQL Server.

    Can anyone help?

    Thanks,

    Michael

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    In SQL it is CASE. Recent thread:
    http://www.dbforums.com/microsoft-sq...lp-needed.html
    Testimonial:
    pootle flump
    ur codings are working excelent.

Posting Permissions

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