Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 SQL Query Question

Author  Topic 

Ecohen
Starting Member

2 Posts

Posted - 2004-12-15 : 16:31:19
I have a SQL Server 2000 database table with details of a "to do list" including the date it is due, and its status (ie-complete, in progress, not started, one-time event).

I want to do a query that will get all of tasks that aren't set to a status of "complete", UNLESS they are a set to a status of "one-time task", in which case, I only want to display it if it is in the future. All the other tasks I want to display whether in the future or past, if they are not set to the staus of "complete". I am having trouble getting my mind around how that query should be written.

The table structure is:

Table Name: toDoList

status - varchar
dateDue - dateTime
comments - text
assignedTo - int

I appreciate help from anyone who can point me in the right direction. Hopefully the answer isn't obvious.

EC

X002548
Not Just a Number

15586 Posts

Posted - 2004-12-15 : 17:04:03
SELECT * FROM toDolist WHERE STATUS NOT IN('complete','one-time task')
UNION ALL
SELECT * FROM toDolist WHERE STATUS = 'one-time task' AND datedue > GetDat()


Brett

8-)
Go to Top of Page

Ecohen
Starting Member

2 Posts

Posted - 2004-12-16 : 05:54:46
That's what I needed! Thanks.
Go to Top of Page
   

- Advertisement -