Solved

Limiting report data

Posted on 2013-01-07
7
151 Views
Last Modified: 2013-01-13
Follow up to this question.

I want to change this query:
SELECT *
FROM [Project List] LEFT JOIN (SELECT * FROM Comments WHERE Comments.[Comment Date]>DateAdd("d",-14,date()))  AS q ON [Project List].ID=q.[Project ID]
WHERE ((([Project List].Resource)=[ResourceFilter]));

Open in new window


So that it does not return projects that are "completed" with a completion date > 14 days ago.

Relevant fields:
[Project List].[Closed Date]
[Project List].[Status]

Open in new window


The value for "Status" for completed projects is "99 Complete"
0
Comment
Question by:nap0leon
  • 4
  • 3
7 Comments
 
LVL 8

Expert Comment

by:Barry62
ID: 38751649
SELECT *
FROM [Project List] LEFT JOIN (SELECT * FROM Comments WHERE Comments.[Comment Date]>DateAdd("d",-14,date()))  AS q ON [Project List].ID=q.[Project ID]
WHERE [Project List].[Status] = "99 Complete" and ([Project List].[Closed Date] < DATE_SUB(date,INTERVAL 14 DAY)) and ((([Project List].Resource)=[ResourceFilter]));

Open in new window

0
 
LVL 18

Accepted Solution

by:
nap0leon earned 0 total points
ID: 38751824
Correcting the above for syntax errors, I have:
SELECT *
FROM [Project List] LEFT JOIN (SELECT * FROM Comments WHERE Comments.[Comment Date]>DateAdd("d",-14,date()))  AS q ON [Project List].ID=q.[Project ID]
WHERE ([Project List].[Status] = "99 Complete" and ([Project List].[Closed Date] < DateAdd("d",-14,date())) and ([Project List].Resource)=[ResourceFilter]);

Open in new window


However, this returns only projects that are closed less than 14 days ago.  I need it to ignore items that are closed more than 2 weeks ago.

I've come up with the following, which ignores the Status field and instead relies only on the value of "Complete Date":
SELECT *
FROM [Project List] LEFT JOIN (SELECT * FROM Comments WHERE Comments.[Comment Date]>DateAdd("d",-14,date()))  AS q ON [Project List].ID=q.[Project ID]
WHERE (([Project List].[Closed Date]>DateAdd("d",-14,date()) Or ([Project List].[Closed Date] Is Null)) And ([Project List].Resource)=[ResourceFilter]);

Open in new window

0
 
LVL 18

Author Comment

by:nap0leon
ID: 38754875
I've requested that this question be deleted for the following reason:

Solved it myself
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 8

Expert Comment

by:Barry62
ID: 38754876
Although my syntax was a bit off, I did provide you with the mysql function (date_sub) which inspired your fix.
0
 
LVL 18

Author Comment

by:nap0leon
ID: 38754996
Actually no.  

I had already decided that I did not need to look at "Status" and would instead simply filter on "Closed Date".

For the Projects Filter, I am using the DateAdd (the same as I am already using in the Comments filter section) and a test that allows NULL.

Besides... You had it backwards (showing only stuff that was closed in the past two weeks rather than showing everything except what was closed over 2 weeks ago.

Thank you for trying, but, honestly, I used absolutely nothing from your solution.
0
 
LVL 8

Expert Comment

by:Barry62
ID: 38755883
Fair enough.  I tried.  I won't object to you closing the question.
0
 
LVL 18

Author Closing Comment

by:nap0leon
ID: 38771606
Solved it myself
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now