Results 1 to 4 of 4
  1. #1
    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
    Ryan
    My Blog

  2. #2
    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?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    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
    Ryan
    My Blog

  4. #4
    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
    aka "Paul"
    Non est ei similis.

    I just read "100 Things To Do Before You Die". I was surprised that "Yell for help!!" wasn't one of them

Posting Permissions

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