Re: Crosstab counting
- From: "ablatnik via AccessMonster.com" <u44170@uwe>
- Date: Tue, 10 Feb 2009 04:06:41 GMT
Michel, thanks for the response. I've built the table as shown, built the
sql query exactly as shown. But when I run the query, I get no data
populating in the query answer table. I checked the table just to ensure
the data was not appending itself there. No go.
I started reading up on joins at wikipedia.com and that has got me even more
confused that I laughed at some of the paragraphs.
After reading the syntex sql multiple times, I can see the statement forming
a sentence. I just don't know why there is no answer. I have 1200 records
in the [Work Orders] table starting at the beginning of this year. I'm sure
something has to match or fall within the criteria.
For created the folling table:
TimeLimits
The Field Names and Data Type are listed:
LowerLimit, Number
UpperLimit, Number
LimitName, Text
The SQL query is the same as yours:
SELECT LimitName, Count(*)
FROM [Work Orders] INNER JOIN TimeLimits ON ([Work Orders].[Date Opened]<Date
()+TimeLimits.UpperLimit) AND ([Work Orders].[Date Opened]>=Date()+TimeLimits.
LowerLimit)
GROUP BY LimitName;
I've read it over and over and I got nothing. What am I missing. The SQL is
not erroring out either. It runs fine but with no data.
Michel Walsh wrote:
The example was about the table, its fields, and data in its four records.
You would have to fill the data in the table, manually. After all, it is
only four records (one per period of time). In fact, the records are about
the offset to be added to the actual Date, as in Date() + LowerLimit
and Date() + UpperLimit becoming, as example, for the second period:
Date() + -30 and Date() + -60, or, if you prefer, between 30 and 60 days
from now (in the past).
That was how about the data would be in that new table: you fill that small
table (small, but useful) manually, as your requirements for the periods
are.
About how it is read? Well, just have to add it in the FROM clause.
if WorkOrders has the records:
DateOpen
X-12
X-67
and
If we were using a Cartesian join:
SELECT WorkOrders.DateOpen, TimeLimits.LowerLimit, TimeLimits.UpperLimit
FROM WorkOrders, TimeLimits
where X == today, then
we could have got:
DateOpen LowerLimit UpperLimit
X-12 0 -30
X-12 -30 -60
X-12 -60 -90
X-12 -90 -10000
X-67 0 -30
X-67 -30 -60
X-67 -60 -90
X-67 -90 -10000
Now, adding the inner join, only the combinations satisfying the ON clause
would be kept:
ON DateOpen >= Date() + LowerLimit
AND DateOpen < Date()+UpperLimit
DateOpen LowerLimit UpperLimit ON clause
X-12 0 -30 true <
keep it
X-12 -30 -60 false
X-12 -60 -90 false
X-12 -90 -10000 false
X-67 0 -30 false
X-67 -30 -60 false
X-67 -60 -90 true <
keep it
X-67 -90 -10000 false
so, the initial records are now in the correct period of time, and we can
use the description we made for that period of time as representative to
the period of time ( or, in SQL general speaking, of "group")
Vanderghast, Access MVP
I'm confused. I understand creating the table with the field names but[quoted text clipped - 51 lines]
the
(Status.Status)
="Active - Damaged") AND (([Work Orders].[Date Opened])<Date()-30));
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-queries/200902/1
.
- References:
- Crosstab counting
- From: ablatnik via AccessMonster.com
- Re: Crosstab counting
- From: Michel Walsh
- Re: Crosstab counting
- From: ablatnik via AccessMonster.com
- Re: Crosstab counting
- From: Michel Walsh
- Crosstab counting
- Prev by Date: RE: Query showing unexpected results
- Next by Date: Re: Crosstab counting
- Previous by thread: Re: Crosstab counting
- Next by thread: Re: Crosstab counting
- Index(es):
Relevant Pages
|