Need help with select case in Access 2007 query

Posted on 2008-11-05
Last Modified: 2012-08-13
Hello, how can I subtract 23 from sum(tblCountData.Incount) only if the value is greater than 0? Using Access 2007

SELECT tblCountData.RecDate, sum(tblCountData.Incount) AS trafficcount
FROM tblCountData
GROUP BY tblCountData.RecDate;
Question by:seanrhudy
    1 Comment
    LVL 48

    Accepted Solution


    SELECT tblCountData.RecDate, IIF(sum(tblCountData.Incount) > 0, sum(tblCountData.Incount)-23, sum(tblCountData.Incount)) AS trafficcount
    FROM tblCountData
    GROUP BY tblCountData.RecDate;

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    In the article entitled Working with Objects – Part 1 (, you learned the basics of working with objects, properties, methods, and events. In Work…
    In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
    With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
    With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now