# Thread: Simplifing Query

1. Registered User
Join Date
Jun 2004
Location
Seattle, WA
Posts
601

## Unanswered: Simplifing Query

I was just wondering if this query for a report can be simplified any.
Code:
```SELECT tblNames.lName+", "+tblNames.fName AS Name, QrySumTotal.[DateRec By Month], QrySumTotal.[Sum Of Cost], QrySumTotal.[Count Of tblRegister]
FROM tblNames INNER JOIN QrySumTotal ON tblNames.ID = QrySumTotal.Pricer
WHERE YEAR(QrySumTotal.[DateRec By Month]) = YEAR(DATE()) AND
((MONTH(QrySumTotal.[DateRec By Month]) = (MONTH(Date())- 3)) OR
(MONTH(QrySumTotal.[DateRec By Month]) = (MONTH(Date())- 2)) OR
(MONTH(QrySumTotal.[DateRec By Month]) = (MONTH(Date())- 1)) OR (MONTH(QrySumTotal.[DateRec By Month]) = (MONTH(DATE()))));```
I am looking to simplify the WHERE statment. This shows only the last 3 months

2. King of Understatement
Join Date
Feb 2004
Location
One Flump in One Place
Posts
14,912
Well.... taking you literally:
Code:
```WHERE YEAR(QrySumTotal.[DateRec By Month]) = YEAR(DATE()) AND
MONTH(QrySumTotal.[DateRec By Month]) BETWEEN MONTH(Date())- 3 AND MONTH(DATE())```
Have you thought about how this will work in January, February and March?

3. Registered User
Join Date
Jun 2004
Location
Seattle, WA
Posts
601
I was assuming it would be a round system. So if you did 2 - 3 = you'd get 12and 11

4. Wayward Son/Black Sheep
Join Date
Feb 2004
Location
Burbank & Santa Cruz de la Sierra
Posts
3,716
every time I responded 12 to the question 2 - 3 = ?, I got a red check mark

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•