A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Query



 
 
Thread Tools Display Modes
  #1  
Old September 23rd, 2004, 05:38 PM
external usenet poster
 
Posts: n/a
Default Query

I have a table in which I have 2 items.

Eg Table Sales
2/22 100
2/23 90

I need to show the difference between the days 2/22 and
2/23. I am drawing a blank.

Can someone help me out.

Thanks
  #2  
Old September 24th, 2004, 01:29 PM
Michel Walsh
external usenet poster
 
Posts: n/a
Default

Hi,



Assuming you have a date_time field, dt, then



SELECT a.dt, LAST(b.sales)-LAST(a.sales)

FROM (myTable As a INNER JOIN myTable As b
ON a.dt b.dt)
INNER JOIN myTable As c
ON a.dt c.dt

GROUP BY a.dt, b.dt
HAVING MIN(c.dt)= b.dt


Basically, we got three references to the original data. we group on each
date_time of a, each date_time of b that are occurring after a, and let c.dt
floating. When the groups are made, (with all possible combinations of a.dt
and b.dt), we keep only those where b.dt = MIN(c.dt), ie, only those of b.dt
immediately following a.dt.

There is a rule telling that we must either include the field in the group
by, either aggregate it, so here, we use LAST over the sales fields, to get
the single value associated to a given reference a, or b.



Hoping it may help,
Vanderghast, Access MVP



wrote in message
...
I have a table in which I have 2 items.

Eg Table Sales
2/22 100
2/23 90

I need to show the difference between the days 2/22 and
2/23. I am drawing a blank.

Can someone help me out.

Thanks



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
query wizard error Christen General Discussion 12 August 13th, 2004 08:37 PM
Query to join records form 2 databases bdehning General Discussion 5 August 9th, 2004 03:09 PM
Display Parameter from Form on Report sara Setting Up & Running Reports 10 July 19th, 2004 04:54 PM
SELECT function in Query alexparks Running & Setting Up Queries 9 July 5th, 2004 11:31 AM
query field reference help -dch Running & Setting Up Queries 4 June 2nd, 2004 07:30 PM


All times are GMT +1. The time now is 08:37 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.