Solved

Limiting report data

Posted on 2013-01-07
7
155 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Application Discovery Service in AWS

In the era of the cloud, customers migrating away from their existing on-premise infrastructure. This requires lots of planning, strategies, and effort to identify their existing resources and determine how best to migrate.  Datacenter migrations happen in four phases -

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

617 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