Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8691007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:02:00+00:00 2026-06-13T00:02:00+00:00

I have executed with no problem the query in SQL but it does not

  • 0

I have executed with no problem the query in SQL but it does not work in Access
Case is not avaliable in Access right, so IIf must be used…

select
    sum(case when date between '2012-05-01' AND '2012-06-01' then value else 0 end) as sum1,
    sum(case when date between '2012-05-01' AND '2012-10-01' then value else 0 end) as sum2,
    sum(case when situation like 'Urgent' then 1 else 0 end) as urgent,
    sum(case when situation like 'Anual' then 1 else 0 end) as anual,
    sum(1) as total
from mytable

Is there a better way of doing this?
Will this query work?

  select
        sum(IIf date between '2012-05-01' AND '2012-06-01',value,0) as sum1,
        sum(IIf date between '2012-05-01' AND '2012-10-01',value,0) as sum2,
        sum(IIf situation like 'Urgent',1,0 ) as urgent,
        sum(IIf situation like 'Anual' ,1,0 ) as anual,
        sum(1) as total
    from mytable
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T00:02:02+00:00Added an answer on June 13, 2026 at 12:02 am

    You need parentheses for IIf() as in IIf(expression, truepart, falsepart)

    Enclose date and value in square brackets because both are reserved words.

    Your Like comparisons didn’t include any pattern matching, so I substituted = instead.

    I assumed date is Date/Time data type, so enclosed the values with the # delimiter.

    SELECT
        Sum(IIf([date] BETWEEN #2012-05-01# AND #2012-06-01#,[value],0)) AS Sum1,
        Sum(IIf([date] BETWEEN #2012-05-01# AND #2012-10-01#,[value],0)) AS Sum2,
        Sum(IIf(situation = 'Urgent',1,0 )) AS urgent,
        Sum(IIf(situation = 'Anual' ,1,0 )) AS anual,
        Sum(1) AS total
    FROM mytable;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a weird problem. When I execute a query the data is not
I have a weird problem with my sql script. I have a string $query
I have this rather simple SQL query, but it takes almost a minute to
I am trying to get the sql query below to work but I am
I have a SQL query which is written in string and then executed using
I have a large project that executes without problem when not debugging (even when
I have executed a code SELECT CASE b.ON_LOAN when 'Y' then 'In Lib' when
I have a query that looks something like this: select xmlelement(rootNode, (case when XH.ID
I have a very complex Linq to SQL query that returns a result set
I understand that if you have some function in a linq query that does

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.