Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 2009
    Posts
    67

    Unanswered: Please help me with this querry

    I have table look like this and I want query that gives me the difference between the ENO for each day compare to previous day. for example the difference between 04/06/09 and 04/05/09 is 35 minus 20 = 15


    Date GNO SNO ENO
    4/3/09 123 12456 3
    4/4/09 123 12456 10
    4/5/09 123 12456 20
    4/6/09 123 12456 35


    Thanks
    Last edited by hmho; 04-07-09 at 00:57.

  2. #2
    Join Date
    May 2005
    Posts
    1,191
    Welcome to the forums.

    I think that can be accomplished with a subquery and the dateadd function. Give it a try and post back how things progress.
    Me.Geek = True

  3. #3
    Join Date
    Apr 2009
    Posts
    67

    please help me whit this query

    How do I do dateadd fucntion I haven't done this before can you give me axample

  4. #4
    Join Date
    May 2005
    Posts
    1,191
    The link that I provided in thread #2 explains the function and gives an example. What have you tried so far?

    To be honest, I'm one of those "Teach a guy to fish" types, though there are others on this forum who are "Give a guy a fish" types. But I want you to try first, as I consider that more help to you than if I just gave the answer to you.
    Me.Geek = True

  5. #5
    Join Date
    Apr 2009
    Posts
    67

    Please help

    date: DateAdd("d",1,[Date]). I was able to do this but how do I get the diffrence between the two days for the field ENO.

    Thanks

  6. #6
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    EDIT - my first post was bunkum.

    Can you post all the SQL you have so far? What you have above is the starting point.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  7. #7
    Join Date
    Apr 2009
    Posts
    67

    Please help me with this query

    SELECT Query_Test_Instant.[Date], Query_Test_Instant.[GNo], Query_Test_Instant.[GNo], Query_Test_Instant.End, Query_Test_Instant.[Face Value], DateAdd("d",1,[Date]) AS [Date]
    FROM Query_Test_Instant
    GROUP BY Query_Test_Instant.[Date], Query_Test_Instant.[GNo], Query_Test_Instant.[GNo], Query_Test_Instant.End, Query_Test_Instant.[Face Value], DateAdd("d",1,[Date])
    HAVING (((Query_Test_Instant.[GNo])=817));

    This what I have and this gives me next day but how do get today's GNO minus yesterday's GNO.

    Please help.

    Thanks

  8. #8
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    This gets you most of the way there:
    Code:
    SELECT *
    FROM Query_Test_Instant AS todays_date
    INNER JOIN Query_Test_Instant AS yesterdays_date
    ON todays_date.GNO= yesterdays_date.GNO
    AND todays_date.SNO = yesterdays_date.SNO
    AND todays_date.[date] = DATEADD("d", 1, yesterdays_date.[date]
    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
  •