Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / February 2008

Tip: Looking for answers? Try searching our database.

Date Range Totals for Logical Fields

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Susan May - 06 Feb 2008 15:05 GMT
Hi All:

I have a database I import from Outlook, and am keeping a list of all active
recruits.  Each week, I need to update 10 logical fields to see how many more
entries were made to each logical question.  What is the best way to get my
results.  I created a query with these fields that did a sum of all these
filds, but when I try to add to the criteria true for "Active Recruit", it
doesn't work; and if I put a lead date range of "Between #12/1/2007# And
#1/31/2008#", It dosn't like that either.  I like the way the sum queries
work - it's one line with all the numbers.  How do I add the criteria to make
this work?  I've spent days trying to figure this out and need someone's help.

Thanks again.

Susan
KARL DEWEY - 06 Feb 2008 15:39 GMT
What kind of fields are [Active Recruit] and [Lead date]?
Signature

KARL DEWEY
Build a little - Test a little

> Hi All:
>
[quoted text clipped - 11 lines]
>
> Susan
Susan May - 06 Feb 2008 15:54 GMT
Active recuit is a true/false field and Lead date is a short date field
[02/06/2008]

> What kind of fields are [Active Recruit] and [Lead date]?
>
[quoted text clipped - 13 lines]
> >
> > Susan
KARL DEWEY - 06 Feb 2008 18:21 GMT
>>Lead date is a short date field
Short date is a format not a datatype.  Is it DateTime or Text datatype?
Signature

KARL DEWEY
Build a little - Test a little

> Active recuit is a true/false field and Lead date is a short date field
> [02/06/2008]
[quoted text clipped - 16 lines]
> > >
> > > Susan
Susan May - 06 Feb 2008 19:28 GMT
It is a date/time field.  I'm reading John's response.  Not quite sure I
understand, but I'm going to try his way unless you have an easier solution.

> >>Lead date is a short date field
> Short date is a format not a datatype.  Is it DateTime or Text datatype?
[quoted text clipped - 19 lines]
> > > >
> > > > Susan
John Spencer - 06 Feb 2008 16:47 GMT
Try adding the fields to the query a second time and change the GROUP BY to
WHERE under the added fields.  Then put your criteria there.  Remove the
criteria under any field that says GROUP By, Sum, etc.

Using the WHERE filters the data before it is aggregated (Summed, Counted,
Averaged, Grouped, etc)

Applying criteria against a field that is aggregated means that the criteria
is applied AFTER the aggregation.  So with a boolean (true/False) field that
is Summed and with the criteria set to TRUE (which is -1), you would be
returning records where the SUM of all the records in the group is equal
to -1.  Probably not going to happen very often.

Signature

John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
.

> Hi All:
>
[quoted text clipped - 16 lines]
>
> Susan
Susan May - 06 Feb 2008 21:58 GMT
John, I'm trying what you said, but the data is coming back incorrect.  It's
not counting the right number of leads based on the date criteria.  I'm at a
loss.

> Try adding the fields to the query a second time and change the GROUP BY to
> WHERE under the added fields.  Then put your criteria there.  Remove the
[quoted text clipped - 29 lines]
> >
> > Susan
John Spencer - 07 Feb 2008 12:19 GMT
Perhaps you could post the SQL statement that is not giving you the expected
results.

Also post one or two rows of data that are "incorrect" and tell us what you
think is "wrong" about the results.

Please  copy and post the SQL of your query.

(Possibly unneeded instructions follow)
Open the query
Select View:Sql from the Menu
Select all the text
Copy it
Paste it into the message

Signature

John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
.

> John, I'm trying what you said, but the data is coming back incorrect.
> It's
[quoted text clipped - 47 lines]
>> >
>> > Susan
Susan May - 07 Feb 2008 15:12 GMT
Hi John:

Here's the Sql statement:

SELECT DISTINCTROW [Qry_AllDDLeads by Date Range].[Lead Date],
Format$([Qry_AllDDLeads by Date Range].[Lead Date],'mmmm yyyy') AS [Lead Date
By Month], [Qry_AllDDLeads by Date Range].[Signed Up], Sum([Qry_AllDDLeads by
Date Range].[Active Recruit]) AS [Sum Of Active Recruit], Sum([Qry_AllDDLeads
by Date Range].[Info Kit Sent]) AS [Sum Of Info Kit Sent],
Sum([Qry_AllDDLeads by Date Range].[Direct Recruit]) AS [Sum Of Direct
Recruit], Sum([Qry_AllDDLeads by Date Range].[Initial Contact Made]) AS [Sum
Of Initial Contact Made], Sum([Qry_AllDDLeads by Date Range].[DD Invite
Letter Sent]) AS [Sum Of DD Invite Letter Sent], Sum([Qry_AllDDLeads by Date
Range].[Accepted DD Invite]) AS [Sum Of Accepted DD Invite],
Sum([Qry_AllDDLeads by Date Range].[Attended DD Mtg]) AS [Sum Of Attended DD
Mtg], Sum([Qry_AllDDLeads by Date Range].[Follow-up After DD Mtg]) AS [Sum Of
Follow-up After DD Mtg], Sum([Qry_AllDDLeads by Date Range].[Has Contract])
AS [Sum Of Has Contract], Count(*) AS [Count Of Qry_AllDDLeads by Date Range]
FROM [Qry_AllDDLeads by Date Range]
GROUP BY [Qry_AllDDLeads by Date Range].[Lead Date], Format$([Qry_AllDDLeads
by Date Range].[Lead Date],'mmmm yyyy'), [Qry_AllDDLeads by Date
Range].[Signed Up], Year([Qry_AllDDLeads by Date Range].[Lead
Date])*12+DatePart('m',[Qry_AllDDLeads by Date Range].[Lead Date])-1
HAVING ((([Qry_AllDDLeads by Date Range].[Lead Date]) Between #1/28/2008#
And #2/1/2008#));

This creates 2 rows:

Lead Date    Lead Date By Month    Signed Up    Sum Of Active Recruit    Sum Of Info Kit
Sent    Sum Of Direct Recruit    Sum Of Initial Contact Made    Sum Of DD Invite
Letter Sent    Sum Of Accepted DD Invite    Sum Of Attended DD Mtg    Sum Of Follow-up
After DD Mtg    Sum Of Has Contract    Count Of Qry_AllDDLeads by Date Range
1/29/2008 1:00:00 PM    January 2008    0    -2    -1    0    0    -1    -1    0    0    0    2
1/30/2008 1:00:00 PM    January 2008    0    -8    -8    0    -1    0    0    0    0    0    8

For the period of 12/28/08 - 2/1/08 when I filter the data in Outlook, I
have 2 leads on 1/29; 8 on 1/30; 7 on 1/31 and 1 on 2/1.  What's strange is
that in other queries, the total number of active recruits in these queries
total 137 which is what I get when I filter in Outlook.  But when I put a
date range in there, it screws up all the data.  None of these fields show
the correct number.  Here's what I get when I filter in Outlook

Week of    Active      Info          Direct     Initial          DD          
DD            
              Recruits  Kits Sent    Recruits  Contact      Invites      
Accepted
                                                          Made
1/28/2008      18    17    2    1    1    1   

Follow-up        #                       #
After DD       Contracts        Signed Up
0          0                 0       

The query is picking up the first two days, but not the rest of the week.  
Why is it not competing the date sequence?  This is driving me crazy as I
must produce this report every week.  Thanks so much for your help.

> Perhaps you could post the SQL statement that is not giving you the expected
> results.
[quoted text clipped - 62 lines]
> >> >
> >> > Susan
John Spencer - 07 Feb 2008 20:19 GMT
Query reformatted for ease of reading

SELECT [Lead Date]
, Format([Lead Date],'mmmm yyyy') AS [Lead Date By Month]
, [Signed Up]
, Sum([Active Recruit]) AS [Sum Of Active Recruit]
, Sum([Info Kit Sent]) AS [Sum Of Info Kit Sent]
, Sum([Direct Recruit]) AS [Sum Of Direct Recruit]
, Sum([Initial Contact Made]) AS [Sum Of Initial Contact Made]
, Sum([DD Invite Letter Sent]) AS [Sum Of DD Invite Letter Sent]
, Sum([Accepted DD Invite]) AS [Sum Of Accepted DD Invite]
, Sum([Attended DD Mtg]) AS [Sum Of Attended DD Mtg]
, Sum([Follow-up After DD Mtg]) AS [Sum Of Follow-up After DD Mtg]
, Sum([Has Contract]) AS [Sum Of Has Contract]
, Count(*) AS [Count Of Qry_AllDDLeads by Date Range]
FROM [Qry_AllDDLeads by Date Range]

WHERE [Lead Date] Between #1/28/2008# And #2/1/2008#

GROUP BY [Lead Date]
, Format([Lead Date],'mmmm yyyy')
, [Signed Up]
, Year([Lead Date])*12+DatePart('m',[Lead Date])-1

Your query should return information for the period 1/28 up to midnight of
2/1  Basically for records where Lead Date runs from 1/28 to 1/31.  IF you
want records for the Feb 1 also, then you need to change the where clause to
WHERE [Lead Date] >= #1/28/2008# And [Lead Date] < #2/2/2008#

I don't have any idea what you are attempting to accomplish with the
expression
, Year([Lead Date])*12+DatePart('m',[Lead Date])-1
That looks as if it is useless to me.

Do you have records for each of the dates 1/28 to 2/1?  This query is only
going to work on those records.  If you have no record for 1/31 then there
will be row returned for that date.

Signature

John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
.

> Hi John:
>
[quoted text clipped - 113 lines]
>> >> >
>> >> > Susan
Susan May - 07 Feb 2008 20:49 GMT
John:  For this date range, I have

2 leads on 1/29
8 leads on 1/30
7 leads on 1/31
1 lead on 2/1

I put the where clause under the Group by Lead Date, and it came back with
36 leads.  Look at the lead dates -- why is it going back to 12/1/07 and not
going thru 2/1?

Lead Date
12/1/2007 1:00:00 PM
12/2/2007 1:00:00 PM
12/3/2007 1:00:00 PM
12/4/2007 1:00:00 PM
12/5/2007 1:00:00 PM
12/6/2007 1:00:00 PM
12/10/2007 1:00:00 PM
12/11/2007 1:00:00 PM
12/12/2007 1:00:00 PM
12/13/2007 1:00:00 PM
12/15/2007 1:00:00 PM
12/16/2007 1:00:00 PM
12/18/2007 1:00:00 PM
12/19/2007 1:00:00 PM
12/20/2007 1:00:00 PM
12/21/2007 1:00:00 PM
12/25/2007 1:00:00 PM
12/26/2007 1:00:00 PM
12/27/2007 1:00:00 PM
12/28/2007 1:00:00 PM
12/29/2007 1:00:00 PM
1/1/2008 1:00:00 PM
1/1/2008 7:08:00 PM
1/2/2008 1:00:00 PM
1/4/2008 1:00:00 PM
1/6/2008 1:00:00 PM
1/7/2008 1:00:00 PM
1/8/2008 1:00:00 PM
1/10/2008 1:00:00 PM
1/11/2008 5:07:00 PM
1/14/2008 1:00:00 PM
1/15/2008 1:00:00 PM
1/17/2008 1:00:00 PM
1/25/2008 1:00:00 PM
1/29/2008 1:00:00 PM
1/30/2008 1:00:00 PM

> Query reformatted for ease of reading
>
[quoted text clipped - 151 lines]
> >> >> >
> >> >> > Susan
John Spencer - 08 Feb 2008 12:26 GMT
I have no idea why it is going back to 12/1/2007.  It is missing the 2/1
record because the DateTime 2/1/2008 01:00:00 PM is after 2/1/2008 00:00:00
AM  IF you wanted that record you would need to change the where clause to
read
  WHERE [Lead Date] >=#1/28/2008# And [Lead Date] < #2/2/2008#

Is there any chance that your Lead Time field is not a date time field but
is a text field that contains a string that looks like a date and time?
Signature

John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
.

> John:  For this date range, I have
>
[quoted text clipped - 223 lines]
>> >> >> >
>> >> >> > Susan
Susan May - 08 Feb 2008 13:59 GMT
John- the field is a true date/time field.  I just rechecked the Where clause
and I have it exactly as you instructed.  Still get records starting on
12/1/07 and ending on 1/30/08.  This just doesn't make any sense.  I just
change the structure of the date field to a short date and that didn't make
the query run any different.  Access should be logical and this is not
logical.  Anybody have any other ideas where I can get weekly leads by this
date field?  Why when you creat this query and you ask it to sum all the
Yes/No fields, does it not have an option for weekly?  It has date/time,
month, quarter, year - not weekly?

Frustrated Susan!

> I have no idea why it is going back to 12/1/2007.  It is missing the 2/1
> record because the DateTime 2/1/2008 01:00:00 PM is after 2/1/2008 00:00:00
[quoted text clipped - 231 lines]
> >> >> >> >
> >> >> >> > Susan
Gary Walter - 12 Feb 2008 10:38 GMT
Hi Susan,

PMFJI

You keep insisting it is a "true date/time field,"
yet your results are "logical" if field is *string*.

Easy test...

SELECT
[Lead Date],
TypeName([Lead Date]) As ActualType
FROM
[Qry_AllDDLeads by Date Range];

good luck,

gary

> John- the field is a true date/time field.  I just rechecked the Where
> clause
[quoted text clipped - 269 lines]
>> >> >> >> >
>> >> >> >> > Susan
Gary Walter - 12 Feb 2008 11:12 GMT
"Gary Walter" <gary@wrotein.msg>

> You keep insisting it is a "true date/time field,"
> yet your results are "logical" if field is *string*.
[quoted text clipped - 6 lines]
> FROM
> [Qry_AllDDLeads by Date Range];

just to show example of why "logical"....

here be how *string dates* would sort

01/01/2008
01/02/2008
01/03/2008
01/04/2008
01/05/2008
01/06/2008
01/07/2008
01/08/2008
01/09/2008
01/10/2008
01/11/2008
01/12/2008
01/13/2008
01/14/2008
01/15/2008
01/16/2008
01/17/2008
01/18/2008
01/19/2008
01/20/2008
01/21/2008
01/22/2008
01/23/2008
01/24/2008
01/25/2008
01/26/2008
01/27/2008
01/28/2008
01/29/2008
01/30/2008
01/31/2008
02/01/2008
02/02/2008 <-- "1/28/2008" would sort after this string
12/01/2007 <-- and before this string
12/02/2007
12/03/2007
12/04/2007
12/05/2007
12/06/2007
12/07/2007
12/08/2007
12/09/2007
12/10/2007
12/11/2007
12/12/2007
12/13/2007
12/14/2007
12/15/2007
12/16/2007
12/17/2007
12/18/2007
12/19/2007
12/20/2007
12/21/2007
12/22/2007
12/23/2007
12/24/2007
12/25/2007
12/26/2007
12/27/2007
12/28/2007
12/29/2007
12/30/2007
12/31/2007
                    <-- "2/1/2008" would sort after last string

anytime you "format" a true date/time,
it becomes a string (which may be what
happened in [Qry_AllDDLeads by Date Range]?

good luck,

gary
Susan May - 12 Feb 2008 16:10 GMT
Hi Gary:

I don't know much about select clauses and subqueries, so I tried putting
this in

Select[Lead Date]), TypeName([Lead Date]) As ActualType From [Qry_AllDDLeads
by Date Range] for [Lead Date] between #2/4/2008# and #2/8/2008#) and got the
error message "Check the subquery's syntax and enclose the subquery in
parenthesis.  I've tried putting parenthesis in several locations and get
different error messages.  What am I doing wrong?

Many thanks for your help.

> "Gary Walter" <gary@wrotein.msg>
>
[quoted text clipped - 86 lines]
>
> gary
Gary Walter - 13 Feb 2008 11:06 GMT
Hi Susan,

I'm sorry if I was not clear, but the test query

SELECT
[Lead Date],
TypeName([Lead Date]) As ActualType
FROM
[Qry_AllDDLeads by Date Range];

was meant to be a stand-alone query to
verify the actual type of the query field

[Qry_AllDDLeads by Date Range].[Lead Date]

my guess was that result of the above query
would show "String" in the ActualType column
based on how the filtering was (not) working for you.

You have provided the SQL for the query
*based on* [Qry_AllDDLeads by Date Range],
but it may help if you provide SQL for this
base query as well.

Are you setting a format of [Lead Date] in the
column "Properties" of either query?

I wonder if that is what you meant by:

" I just change the structure of the date field to a short date
and that didn't make the query run any different."

Again...any time you *format* a pure Date/Time,
it becomes a STRING (and so will sort/filter as
a string, instead of as a Date/Time).

///////////////////////////////////////////
Another thing that may be at first hard to understand
designing a GROUP BY query in the grid ...

"I put the where clause under the Group by Lead Date"

Field:   [Lead Date]
Table: [Qry_AllDDLeads by Date Range]
Total:  GROUP BY
Sort:
Show:
Criteria: BETWEEN #1/28/2008# AND #2/1/2008#
or:

That will produce a HAVING clause. That was not
why the "dates" were filtering as strings, but you will
learn that HAVING can be inefficient because it
does the filtering only after all the groups have been
made and the aggregating has occurred.

To create a WHERE clause, you would need to
add [Lead Date] a second time to grid,
change the GROUP BY to WHERE,
and put your filter dates in that column's
Criteria row (not under original GROUP BY column):

Field:   [Lead Date]
Table: [Qry_AllDDLeads by Date Range]
Total:  WHERE
Sort:
Show:
Criteria: BETWEEN #1/28/2008# AND #2/1/2008#
or:

the above filtering will happen *before* groups
are created and aggregation occurs.

Sometimes the difference between applying the filter
before grouping (WHERE) and applying the filter
after grouping (HAVING) will also effect the results
you get for your aggregate(s) like SUM(...).

///////////////////////////
Another note if you are using Access 2000 or later,
"DISTINCTROW" really is designed for queries
that involve more than one "table source."

Plus, in a GROUP BY query, your "group" should do the
work of creating distinct rows.

/////////////////////////////

if you are tired and frustrated, sometimes a "little success"
can help you out of the "gumption traps."

if our multiple guesses were correct (you have somehow formatted
[Lead Date] into a string, you might copy the following into a new
query just to see some possible "success."

SELECT
Q.[Lead Date] AS LeadDate,
Format$(Q.[Lead Date],'mmmm yyyy') AS LeadDateByMonth,
Q.[Signed Up] AS SignedUp,
Sum(Q.[Active Recruit]) AS SumOfActiveRecruit,
Sum(Q.[Info Kit Sent]) AS SumOfInfoKitSent,
Sum(Q.[Direct Recruit]) AS SumOfDirectRecruit,
Sum(Q.[Initial Contact Made]) AS SumOfInitialContactMade,
Sum(Q.[DD Invite Letter Sent]) AS SumOfDDInviteLetterSent,
Sum(Q.[Accepted DD Invite]) AS SumOfAcceptedDDInvite,
Sum(Q.[Attended DD Mtg]) AS SumOfAttendedDDMtg,
Sum(Q.[Follow-up After DD Mtg]) AS SumOfFollowUpAfterDDMtg,
Sum(Q.[Has Contract]) AS SumOfHasContract,
Count(*) AS LeadCnt
FROM [Qry_AllDDLeads by Date Range] AS Q
GROUP BY
Q.[Lead Date],
Format$(Q.[Lead Date],'mmmm yyyy'),
Q.[Signed Up]
WHERE
CDate(NZ(Q.[Lead Date],#9/9/9999#))
Between
#1/28/2008#
And
#2/1/2008#;

It (very inefficiently) changes [Lead Date] back to a Date/Time
before applying date range in WHERE clause.

If I have not done something stupid (my typing sucks...),
I'd be interested in the results you get....

good luck,

gary

> I don't know much about select clauses and subqueries, so I tried
>putting this in
> Select[Lead Date]), TypeName([Lead Date]) As ActualType From
> [Qry_AllDDLeads by Date Range] for [Lead Date] between
> #2/4/2008# and #2/8/2008#) and got the error message
"Check the subquery's syntax and enclose the subquery in
> parenthesis.  I've tried putting parenthesis in several locations and get
> different error messages.  What am I doing wrong?
Gary Walter - 13 Feb 2008 11:21 GMT
oops...I forgot you have time values in [Lead Date]....

SELECT
Q.[Lead Date] AS LeadDate,
Format$(Q.[Lead Date],'mmmm yyyy') AS LeadDateByMonth,
Q.[Signed Up] AS SignedUp,
Sum(Q.[Active Recruit]) AS SumOfActiveRecruit,
Sum(Q.[Info Kit Sent]) AS SumOfInfoKitSent,
Sum(Q.[Direct Recruit]) AS SumOfDirectRecruit,
Sum(Q.[Initial Contact Made]) AS SumOfInitialContactMade,
Sum(Q.[DD Invite Letter Sent]) AS SumOfDDInviteLetterSent,
Sum(Q.[Accepted DD Invite]) AS SumOfAcceptedDDInvite,
Sum(Q.[Attended DD Mtg]) AS SumOfAttendedDDMtg,
Sum(Q.[Follow-up After DD Mtg]) AS SumOfFollowUpAfterDDMtg,
Sum(Q.[Has Contract]) AS SumOfHasContract,
Count(*) AS LeadCnt
FROM [Qry_AllDDLeads by Date Range] AS Q
GROUP BY
Q.[Lead Date],
Format$(Q.[Lead Date],'mmmm yyyy'),
Q.[Signed Up]
WHERE
CDate(NZ(Q.[Lead Date],"1900-01-01")) >= #1/28/2008#
And
CDate(NZ(Q.[Lead Date],"9999-09-09"))< #2/2/2008#;

note: last date criteria is midnight of "next day"
which will pick up those [Lead Date]'s of 2/1/2008
with a time value

(I hope that's all I goofed on)

good luck,

gary
Susan May - 13 Feb 2008 20:48 GMT
Gary - got this message:

Syntax error (missing operator) in query expression

Q.[Signed Up] WHERE CDate(NZ(Q.[Lead Date],"1900-01-01")) >= #1/28/2008#
And CDate(NZ(Q.[Lead Date],"9999-09-09"))< #2/2/2008#;

Can you send me back the code with the missing operator?  I can't figure out
what's missing here.

Thanks a bunch!

> oops...I forgot you have time values in [Lead Date]....
>
[quoted text clipped - 31 lines]
>
> gary
Gary Walter - 13 Feb 2008 23:16 GMT
I don't see anything "wrong"...

Are you saying you copied the SQL
into SQL View of a *new query*, and
when you went into Design View it gave
you a syntax error.

Or, once you copied the SQL
into SQL View of a *new query*,
you could go into Design View,
but when you tried to save it, it gave
you a syntax error.

Did you just temporarily delete the
WHERE clause while in SQL View
to see if error went away -- so we
know error is in WHERE clause
(or in copy-pasting of SQL?).

If you copy the following to a new
query in SQL View, do you get an
error?

SELECT
Q.[Lead Date] AS LeadDate,
Format$(Q.[Lead Date],'mmmm yyyy') AS LeadDateByMonth,
Q.[Signed Up] AS SignedUp,
Sum(Q.[Active Recruit]) AS SumOfActiveRecruit,
Sum(Q.[Info Kit Sent]) AS SumOfInfoKitSent,
Sum(Q.[Direct Recruit]) AS SumOfDirectRecruit,
Sum(Q.[Initial Contact Made]) AS SumOfInitialContactMade,
Sum(Q.[DD Invite Letter Sent]) AS SumOfDDInviteLetterSent,
Sum(Q.[Accepted DD Invite]) AS SumOfAcceptedDDInvite,
Sum(Q.[Attended DD Mtg]) AS SumOfAttendedDDMtg,
Sum(Q.[Follow-up After DD Mtg]) AS SumOfFollowUpAfterDDMtg,
Sum(Q.[Has Contract]) AS SumOfHasContract,
Count(*) AS LeadCnt
FROM [Qry_AllDDLeads by Date Range] AS Q
GROUP BY
Q.[Lead Date],
Format$(Q.[Lead Date],'mmmm yyyy'),
Q.[Signed Up]
WHERE
Q.[Lead Date] >= #1/28/2008#
And
Q.[Lead Date] < #2/2/2008#;

"Susan May"wrote:
> Gary - got this message:
>
[quoted text clipped - 44 lines]
>>
>> gary
Gary Walter - 13 Feb 2008 23:41 GMT
sorry!!!!! WHERE clause goes before GROUP BY clause!!!!
queries 101!!!!

try...

SELECT
Q.[Lead Date] AS LeadDate,
Format$(Q.[Lead Date],'mmmm yyyy') AS LeadDateByMonth,
Q.[Signed Up] AS SignedUp,
Sum(Q.[Active Recruit]) AS SumOfActiveRecruit,
Sum(Q.[Info Kit Sent]) AS SumOfInfoKitSent,
Sum(Q.[Direct Recruit]) AS SumOfDirectRecruit,
Sum(Q.[Initial Contact Made]) AS SumOfInitialContactMade,
Sum(Q.[DD Invite Letter Sent]) AS SumOfDDInviteLetterSent,
Sum(Q.[Accepted DD Invite]) AS SumOfAcceptedDDInvite,
Sum(Q.[Attended DD Mtg]) AS SumOfAttendedDDMtg,
Sum(Q.[Follow-up After DD Mtg]) AS SumOfFollowUpAfterDDMtg,
Sum(Q.[Has Contract]) AS SumOfHasContract,
Count(*) AS LeadCnt
FROM [Qry_AllDDLeads by Date Range] AS Q
WHERE
CDate(NZ(Q.[Lead Date],"1900-01-01")) >= #1/28/2008#
And
CDate(NZ(Q.[Lead Date],"9999-09-09"))< #2/2/2008#
GROUP BY
Q.[Lead Date],
Format$(Q.[Lead Date],'mmmm yyyy'),
Q.[Signed Up];

"Gary Walter" <gary@wrotein.msg>
>I don't see anything "wrong"...
>
[quoted text clipped - 92 lines]
>>>
>>> gary
Susan May - 14 Feb 2008 19:51 GMT
Wow Gary:  I'm getting 2 error messages wanting me to enter Parameter value,
but I don't even see them listed in the query, they are:

DD2 List.Info Kit Date Sent - Enter Parameter Value
Q.Info Kit Sent

So, when I bypass this, there are not values that appear.  I think we are
getting closer, but not there yet.

Again, I appreciate you helping me as I am no programmer and want to
streamline this reporting process.

> sorry!!!!! WHERE clause goes before GROUP BY clause!!!!
> queries 101!!!!
[quoted text clipped - 122 lines]
> >>>
> >>> gary
Gary Walter - 14 Feb 2008 20:59 GMT
Hi Susan,

Please post the SQL for your query

[Qry_AllDDLeads by Date Range]

(i.e., go to SQL View of above query,
copy it and paste into post back to here)

thanks,

gary

> Wow Gary:  I'm getting 2 error messages wanting me to enter Parameter
> value,
[quoted text clipped - 137 lines]
>> >>>
>> >>> gary
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.