Re: Today and Yesterday
- From: "RogueIT" <RogueIT@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 21 Jul 2005 12:53:01 -0700
I have several days worth of data, companies will have multiple entries into
the Information_coll.
I use this query to show me how many entries are in table Information_coll
So if id is in information_coll 5 times it will show me the number 5 in the
front-end query.
******************count of ID**********************************
SELECT Information_coll.[ID ], Count(Information_coll.[ID ]) AS CountOfID
FROM Information_coll
GROUP BY Information_coll.[ID ];
************************************************************
The preferred result would be if a company has an entry from yesterday and
day before, but no other entries in the table.
How would I set the criteria on the information_coll.date field to show me
that?
Examples of what I don't want to see are
Id with a count of 1 or 3 or >3
Id's with date entries before 2 days ago.
Right now I am getting all entries with a date = date() -1, so if a company
has 4 entries but one of the entries = date() -1 then I get them in the
results...
I never have been a good explainer, if there is some more date that I can
give you to help me just let me know.
Thanks,
RogueIT
"Steve Schapel" wrote:
> RogueIT,
>
> I gather that the query you posted does not give the expected results?
> In what way is it different from expected?
>
> It is not clear what the purpose of the GROUP BY clause in the query is.
> Nor is it clear what the role of the fields from the Count_ID query
> play, but I imagine there is only one record returned in this query for
> each company, yes? Also, 'count' and 'date' are both Reserved Words
> (i.e. have a special meaning) in Access, and as such should not be used
> as the name of fileds or controls... but that is unlikely to be causing
> the problem. The Last() function returns a random record, probably you
> need Max(). Is the data in the [Date] field just a date, or does it
> include time data as well? Assuming just a date:
>
> I would try it like this...
> SELECT DISTINCT Count_ID.[ID ], Count_ID.CountOfID AS [Count],
> Information_coll.[Company Name], Information_coll.[Date]
> FROM Information_coll INNER JOIN Count_ID ON Information_coll.[ID] =
> Count_ID.[ID]
> WHERE Information_coll.[Date]=Date()-1 Or Information_coll.[Date]=Date()-2
> ORDER BY Count_ID.CountOfID DESC;
>
> or...
> SELECT Count_ID.[ID ], Count_ID.CountOfID AS [Count],
> Information_coll.[Company Name ], Max(Information_coll.[Date]) AS MaxOfDate
> FROM Information_coll INNER JOIN Count_ID ON Information_coll.[ID] =
> Count_ID.[ID]
> GROUP BY Count_ID.[ID], Count_ID.CountOfID, Information_coll.[Company Name]
> HAVING ((Max(Information_coll.[Date]))=Date()-1 Or
> (Max(Information_coll.[Date]))=Date()-2)
> ORDER BY Count_ID.CountOfID DESC;
>
> If neither of these help, please let us know what the problem is.
>
> --
> Steve Schapel, Microsoft Access MVP
>
>
> RogueIT wrote:
> > How would I have it only show me only the companies that have entries in the
> > table for today and yesterday (technically it would be yesterday and day
> > before that ) so companies that have consecutive days from yesterday
> > *******************************************
> > SELECT Count_ID.[ID ], Count_ID.CountOfID AS [Count],
> > Information_coll.[Company Name ], Last(Information_coll.Date) AS LastOfDate
> > FROM Information_coll INNER JOIN Count_ID ON Information_coll.[ID ] =
> > Count_ID.[ID ]
> > GROUP BY Count_ID.[ID ], Count_ID.CountOfID, Information_coll.[Company Name ]
> > HAVING (((Last(Information_coll.Date))=Date()-1 Or
> > (Last(Information_coll.Date))=Date()-2))
> > ORDER BY Count_ID.CountOfID DESC;
> > *******************************************
>
.
- Follow-Ups:
- Re: Today and Yesterday
- From: Steve Schapel
- Re: Today and Yesterday
- References:
- Today and Yesterday
- From: RogueIT
- RE: Today and Yesterday
- From: Chaim
- RE: Today and Yesterday
- From: RogueIT
- Re: Today and Yesterday
- From: Steve Schapel
- Today and Yesterday
- Prev by Date: slow response time in Access 2002 using a date variable for criter
- Next by Date: Re: Group Data by Week
- Previous by thread: Re: Today and Yesterday
- Next by thread: Re: Today and Yesterday
- Index(es):
Relevant Pages
|