Advertisement

05.22.2008 at 11:39AM PDT, ID: 23425469
[x]
Attachment Details

Need to create SQL query with time filer

Asked by atoncelli in MS SQL Server

Tags: Microsoft, SQL on ClearQuest, 2003, SQL query

Hello,
 I have running ClearQuest on Windows and I am trying to create a query that has a time filter.  In a nutshell, I want to query for all the defects that are not closed and the ones that are closed but only in the last 15 days.  I tried to create the query but I can get it to work only if I use a specific day and time (ts).  Here are my queries.

This one works fine:

select distinct T1.dbid,T1.id,T1.title,T2.name from Defect T1,statedef T2,project T4 where T1.state = T2.id and T1.project = T4.dbid and (T1.dbid <> 0 and ((T4.name = 'Project 1' and ((T2.name = 'Closed' and T1.closed_date >= {ts '2008-05-12 04:00:00'}) or ((T2.name <> 'Closed' or T1.state = 0)))))) order by T1.id ASC

But if I change the time to use sysdate it doesn't work anymore:

select distinct T1.dbid,T1.id,T2.name, T1.title from Defect T1,statedef T2,project T3 where T1.state = T2.id and T1.project = T3.dbid and (T1.dbid <> 0 and (( ( (T2.name <> 'Closed' or T1.state = 0) or (T2.name = 'Closed' and T1.closed_date >(sysdate - 15 ))and T3.name = 'Project 1'))) order by T1.id ASC

Any suggestions?
ThanksStart Free Trial
[+][-]05.22.2008 at 11:45AM PDT, ID: 21626454

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.22.2008 at 11:46AM PDT, ID: 21626458

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.22.2008 at 11:48AM PDT, ID: 21626479

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.22.2008 at 11:49AM PDT, ID: 21626492

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.22.2008 at 12:00PM PDT, ID: 21626613

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: MS SQL Server
Tags: Microsoft, SQL on ClearQuest, 2003, SQL query
Sign Up Now!
Solution Provided By: YZlat
Participating Experts: 1
Solution Grade: A
 
 
[+][-]05.22.2008 at 12:16PM PDT, ID: 21626756

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628