Results 1 to 3 of 3
  1. #1
    Fabdav is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2011
    Posts
    22

    result of a query depending on the date value (file is attached)

    (File attached)
    I have two separate query: the first shows the sum of value in a period of 36 months from an entered data, the second query show for a period of 500.
    I have tried with a IFF but with no success.
    These are the two queries:



    SELECT ST.L, Sum(ST.C) AS TOT
    FROM ST
    WHERE (((ST.B)>DateAdd("m",-500,Date())))
    GROUP BY ST.L;


    SELECT ST.L, Sum(ST.C) AS TOT
    FROM ST
    WHERE (((ST.B)>DateAdd("m",-1,Date())))
    GROUP BY ST.L;

    I would like have the this in a single query so I can display immediatelly the result

    If tried this:
    SELECT Sum(IIf(B > DateAdd("m",-500,Date(), C, 0)) AS Tot, Sum(IIf(B > DateAdd("m",-1,Date(), C, 0)) AS Tot1
    From ST

    But it is wrong
    Last edited by Fabdav; 09-18-2011 at 03:24 AM.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I'm not clear on what your question is. What is it you're trying to achieve? Perhaps if you posted the IIf() that didn't work.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Fabdav is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2011
    Posts
    22
    I have figured out:

    SELECT ST.L, Sum(IIf(((([B])>DateAdd("m",-1,Date()))),[C],0)) AS T1, Sum(IIf(((([B])>DateAdd("m",-500,Date()))),[C],0)) AS T2
    FROM ST
    GROUP BY ST.L;

Please reply to this thread with any new information or opinions.

Similar Threads

  1. VB ADO Query Result Set
    By Bedsingar in forum Access
    Replies: 5
    Last Post: 09-05-2011, 10:45 AM
  2. When a query result is empty.....
    By khanson in forum Queries
    Replies: 3
    Last Post: 08-01-2011, 09:12 PM
  3. combine query result
    By Fenvy in forum Queries
    Replies: 1
    Last Post: 06-22-2011, 05:02 PM
  4. Return DLookup result as date?
    By kman42 in forum Access
    Replies: 8
    Last Post: 04-22-2011, 11:35 AM
  5. Result of Count Query not known elsewhere
    By Carole in forum Access
    Replies: 1
    Last Post: 09-07-2008, 09:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums